@systemfsoftware/effect-daemon-spec 5.1.0 → 6.0.3

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
@@ -6,9 +6,7 @@ Every supervision decision is made by a pure fold over supervision events, and e
6
6
 
7
7
  ## Install
8
8
 
9
- ```bash
10
- pnpm add @systemfsoftware/effect-daemon-spec effect
11
- ```
9
+ This package is not on npm: take `@systemfsoftware/effect-daemon-spec` from nix.systemfsoftware.com, the package registry for `@systemfsoftware` packages, through a flake input (see the repository README). Install `effect` beside it.
12
10
 
13
11
  > [!NOTE]
14
12
  > `effect` is a peer dependency: you bring your own.
@@ -153,4 +151,4 @@ The wait succeeds when the supervisor ended because it was asked to shut down or
153
151
 
154
152
  ## License
155
153
 
156
- [Apache-2.0](https://github.com/systemfsoftware/systemfsoftware/blob/main/packages/daemon/effect-daemon-spec/LICENSE)
154
+ [Apache-2.0](https://github.com/systemfsoftware/effect-daemon/blob/main/packages/effect-daemon-spec/LICENSE)
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { Handle, Workflow } from "@systemfsoftware/effect-cell-types";
2
- import { Cause, Context, Deferred, Effect, Exit, HashMap, Layer, Option, PubSub, Queue, Ref, Schema, Scope } from "effect";
2
+ import { Cause, Context, Deferred, Effect, HashMap, Layer, Option, PubSub, Queue, Ref, Schema, Scope } from "effect";
3
3
  import * as Stream from "effect/Stream";
4
4
  import { Pipeable } from "effect/Pipeable";
5
- //#region src/kernel/TerminationReport.schema.d.ts
6
5
  /**
7
6
  * What a medium can say about why a child died (R16): a fiber supplies a cause, a process
8
7
  * supplies an exit status and signal, and a remote runner's death is inferred. No event
@@ -67,10 +66,8 @@ declare const TerminationReason: Schema.Union<readonly [Schema.TaggedStruct<"Nor
67
66
  }>]>;
68
67
  }>]>;
69
68
  type TerminationReason = typeof TerminationReason.Type;
70
- //#endregion
71
- //#region src/Supervisor/SupervisorTerminated.schema.d.ts
72
69
  declare const SupervisorTerminated_base: Schema.Class<SupervisorTerminated, Schema.TaggedStruct<"SupervisorTerminated", {
73
- readonly name: Schema.String;
70
+ readonly supervisor: Schema.String;
74
71
  readonly reason: Schema.Union<readonly [Schema.TaggedStruct<"Normal", {}>, Schema.TaggedStruct<"Shutdown", {}>, Schema.TaggedStruct<"Abnormal", {
75
72
  readonly report: Schema.Union<readonly [Schema.TaggedStruct<"CauseReport", {
76
73
  readonly cause: Schema.String;
@@ -84,48 +81,50 @@ declare const SupervisorTerminated_base: Schema.Class<SupervisorTerminated, Sche
84
81
  }>]>;
85
82
  }>]>;
86
83
  readonly cause: Schema.Cause<Schema.Unknown, Schema.Unknown>;
87
- }>, Cause.YieldableError>;
84
+ }>, Cause.YieldableError & {
85
+ readonly brand: unique symbol;
86
+ }>;
88
87
  declare class SupervisorTerminated extends SupervisorTerminated_base {
89
88
  get message(): string;
90
89
  }
91
- //#endregion
92
- //#region src/Supervisor/ChildExitDecision.schema.d.ts
93
90
  declare const ChildExitTypeId: unique symbol;
94
91
  type ChildExitTypeId = typeof ChildExitTypeId;
95
- declare const NormalExit_base: Schema.Class<NormalExit, Schema.TaggedStruct<"Normal", {}>, {}>;
92
+ declare const NormalExit_base: Schema.Class<NormalExit, Schema.TaggedStruct<"Normal", {}>, {
93
+ readonly brand: unique symbol;
94
+ }>;
96
95
  /** The child ended on its own success. */
97
96
  declare class NormalExit extends NormalExit_base {
98
97
  readonly [ChildExitTypeId]: symbol;
99
98
  }
100
- declare const ShutdownExit_base: Schema.Class<ShutdownExit, Schema.TaggedStruct<"Shutdown", {}>, {}>;
99
+ declare const ShutdownExit_base: Schema.Class<ShutdownExit, Schema.TaggedStruct<"Shutdown", {}>, {
100
+ readonly brand: unique symbol;
101
+ }>;
101
102
  /** The child was interrupted — an owned shutdown, or one it raised itself. */
102
103
  declare class ShutdownExit extends ShutdownExit_base {
103
104
  readonly [ChildExitTypeId]: symbol;
104
105
  }
105
- declare const AbnormalExit_base: Schema.Class<AbnormalExit, Schema.TaggedStruct<"Abnormal", {}>, {}>;
106
+ declare const AbnormalExit_base: Schema.Class<AbnormalExit, Schema.TaggedStruct<"Abnormal", {}>, {
107
+ readonly brand: unique symbol;
108
+ }>;
106
109
  /** The child failed with something other than an interruption. */
107
110
  declare class AbnormalExit extends AbnormalExit_base {
108
111
  readonly [ChildExitTypeId]: symbol;
109
112
  }
110
- //#endregion
111
- //#region src/Supervisor/classify-child-exit.workflow.d.ts
112
113
  declare const ClassifyChildExit_base: Schema.Class<ClassifyChildExit, Schema.TaggedStruct<"ClassifyChildExit", {
113
114
  readonly stopping: Schema.Boolean;
114
115
  readonly exit: Schema.Exit<Schema.Void, Schema.Unknown, Schema.Unknown>;
115
- }>, {}>;
116
+ }>, {
117
+ readonly brand: unique symbol;
118
+ }>;
116
119
  declare class ClassifyChildExit extends ClassifyChildExit_base {
117
120
  static readonly [Workflow.InstrumentationBrand]: {};
118
121
  }
119
122
  declare const classifyChildExit: Workflow.MadeWorkflow<typeof ClassifyChildExit, Schema.Union<readonly [typeof NormalExit, typeof ShutdownExit, typeof AbnormalExit]>, Schema.Never>;
120
- //#endregion
121
- //#region src/kernel/SupervisionLimits.schema.d.ts
122
123
  /** How many times a child incarnation has been replaced: any non-negative safe integer. Generation stays small so generation+1 stays in range. */
123
124
  declare const Generation: Schema.Int;
124
125
  type Generation = typeof Generation.Type;
125
126
  declare const ChildId: Schema.String;
126
127
  type ChildId = typeof ChildId.Type;
127
- //#endregion
128
- //#region src/kernel/SupervisorPolicy.schema.d.ts
129
128
  declare const RestartStrategy: Schema.Literals<readonly ["one_for_one", "one_for_all", "rest_for_one"]>;
130
129
  type RestartStrategy = typeof RestartStrategy.Type;
131
130
  declare const AutoShutdown: Schema.Literals<readonly ["never", "any_significant", "all_significant"]>;
@@ -169,8 +168,6 @@ declare const DynamicKind: Schema.Union<readonly [Schema.TaggedStruct<"NoDynamic
169
168
  readonly probeFailureThreshold: Schema.Int;
170
169
  }>]>;
171
170
  type DynamicKind = typeof DynamicKind.Type;
172
- //#endregion
173
- //#region src/Supervisor/MediumDeclaration.schema.d.ts
174
171
  /**
175
172
  * What a medium can say about why a child died (R16, KTD8): the in-process fiber
176
173
  * medium reports a full `Cause`, a process, socket or microVM medium reports the
@@ -273,8 +270,6 @@ declare const fiberPort: import("effect/Context").Service<MediumPortShape<FiberP
273
270
  declare const failureCauseOf: (evidence: Started) => Option.Option<Effect.Effect<Option.Option<Cause.Cause<SupervisorTerminated>>>>;
274
271
  declare const mediumFor: <R = never>() => Medium<(ready: Effect.Effect<void>) => Effect.Effect<void, SupervisorTerminated, Scope.Scope | R>, never, Scope.Scope | R>;
275
272
  declare const medium: Medium<FiberProgram, never, Scope.Scope>;
276
- //#endregion
277
- //#region src/kernel/SupervisorState.schema.d.ts
278
273
  declare const StateTypeId: unique symbol;
279
274
  declare const Running_base: Schema.Class<Running, Schema.TaggedStruct<"Running", {
280
275
  readonly core: Schema.Struct<{
@@ -322,7 +317,9 @@ declare const Running_base: Schema.Class<Running, Schema.TaggedStruct<"Running",
322
317
  readonly restartStamps: Schema.$Array<Schema.Int>;
323
318
  readonly nextOrdinal: Schema.Int;
324
319
  }>;
325
- }>, {}>;
320
+ }>, {
321
+ readonly brand: unique symbol;
322
+ }>;
326
323
  declare class Running extends Running_base {
327
324
  readonly [StateTypeId]: symbol;
328
325
  }
@@ -376,7 +373,9 @@ declare const Restarting_base: Schema.Class<Restarting, Schema.TaggedStruct<"Res
376
373
  readonly childId: Schema.String;
377
374
  readonly generation: Schema.Int;
378
375
  }>>;
379
- }>, {}>;
376
+ }>, {
377
+ readonly brand: unique symbol;
378
+ }>;
380
379
  declare class Restarting extends Restarting_base {
381
380
  readonly [StateTypeId]: symbol;
382
381
  }
@@ -427,7 +426,9 @@ declare const CoolingDown_base: Schema.Class<CoolingDown, Schema.TaggedStruct<"C
427
426
  readonly nextOrdinal: Schema.Int;
428
427
  }>;
429
428
  readonly millis: Schema.Int;
430
- }>, {}>;
429
+ }>, {
430
+ readonly brand: unique symbol;
431
+ }>;
431
432
  declare class CoolingDown extends CoolingDown_base {
432
433
  readonly [StateTypeId]: symbol;
433
434
  }
@@ -493,7 +494,9 @@ declare const ShuttingDown_base: Schema.Class<ShuttingDown, Schema.TaggedStruct<
493
494
  readonly childId: Schema.String;
494
495
  readonly generation: Schema.Int;
495
496
  }>]>;
496
- }>, {}>;
497
+ }>, {
498
+ readonly brand: unique symbol;
499
+ }>;
497
500
  declare class ShuttingDown extends ShuttingDown_base {
498
501
  readonly [StateTypeId]: symbol;
499
502
  }
@@ -510,16 +513,18 @@ declare const Terminated_base: Schema.Class<Terminated, Schema.TaggedStruct<"Ter
510
513
  readonly waitedMillis: Schema.Int;
511
514
  }>]>;
512
515
  }>]>;
513
- }>, {}>;
516
+ }>, {
517
+ readonly brand: unique symbol;
518
+ }>;
514
519
  declare class Terminated extends Terminated_base {
515
520
  readonly [StateTypeId]: symbol;
516
521
  }
517
522
  declare const SupervisorState: Schema.Union<readonly [typeof Running, typeof Restarting, typeof CoolingDown, typeof ShuttingDown, typeof Terminated]>;
518
523
  type SupervisorState = typeof SupervisorState.Type;
519
- //#endregion
520
- //#region src/kernel/interpret-supervision-event.workflow.d.ts
521
524
  declare const DecisionTypeId: unique symbol;
522
- declare const Stale_base: Schema.Class<Stale, Schema.TaggedStruct<"Stale", {}>, {}>;
525
+ declare const Stale_base: Schema.Class<Stale, Schema.TaggedStruct<"Stale", {}>, {
526
+ readonly brand: unique symbol;
527
+ }>;
523
528
  declare class Stale extends Stale_base {
524
529
  readonly [DecisionTypeId]: symbol;
525
530
  }
@@ -618,7 +623,9 @@ declare const Continue_base: Schema.Class<Continue, Schema.TaggedStruct<"Continu
618
623
  }>]>;
619
624
  }>>;
620
625
  }>;
621
- }>, {}>;
626
+ }>, {
627
+ readonly brand: unique symbol;
628
+ }>;
622
629
  declare class Continue extends Continue_base {
623
630
  readonly [DecisionTypeId]: symbol;
624
631
  }
@@ -721,7 +728,9 @@ declare const RestartChildren_base: Schema.Class<RestartChildren, Schema.TaggedS
721
728
  }>]>;
722
729
  }>>;
723
730
  }>;
724
- }>, {}>;
731
+ }>, {
732
+ readonly brand: unique symbol;
733
+ }>;
725
734
  declare class RestartChildren extends RestartChildren_base {
726
735
  readonly [DecisionTypeId]: symbol;
727
736
  }
@@ -820,7 +829,9 @@ declare const StartChildren_base: Schema.Class<StartChildren, Schema.TaggedStruc
820
829
  }>]>;
821
830
  }>>;
822
831
  }>;
823
- }>, {}>;
832
+ }>, {
833
+ readonly brand: unique symbol;
834
+ }>;
824
835
  declare class StartChildren extends StartChildren_base {
825
836
  readonly [DecisionTypeId]: symbol;
826
837
  }
@@ -920,7 +931,9 @@ declare const CoolDown_base: Schema.Class<CoolDown, Schema.TaggedStruct<"CoolDow
920
931
  }>]>;
921
932
  }>>;
922
933
  }>;
923
- }>, {}>;
934
+ }>, {
935
+ readonly brand: unique symbol;
936
+ }>;
924
937
  declare class CoolDown extends CoolDown_base {
925
938
  readonly [DecisionTypeId]: symbol;
926
939
  }
@@ -1035,7 +1048,9 @@ declare const StopChildren_base: Schema.Class<StopChildren, Schema.TaggedStruct<
1035
1048
  }>]>;
1036
1049
  }>>;
1037
1050
  }>;
1038
- }>, {}>;
1051
+ }>, {
1052
+ readonly brand: unique symbol;
1053
+ }>;
1039
1054
  declare class StopChildren extends StopChildren_base {
1040
1055
  readonly [DecisionTypeId]: symbol;
1041
1056
  }
@@ -1101,7 +1116,9 @@ declare const Terminate_base: Schema.Class<Terminate, Schema.TaggedStruct<"Termi
1101
1116
  }>]>;
1102
1117
  }>>;
1103
1118
  }>;
1104
- }>, {}>;
1119
+ }>, {
1120
+ readonly brand: unique symbol;
1121
+ }>;
1105
1122
  declare class Terminate extends Terminate_base {
1106
1123
  readonly [DecisionTypeId]: symbol;
1107
1124
  }
@@ -1155,14 +1172,14 @@ declare const RefuseDynamicStart_base: Schema.Class<RefuseDynamicStart, Schema.T
1155
1172
  }>]>;
1156
1173
  }>>;
1157
1174
  }>;
1158
- }>, {}>;
1175
+ }>, {
1176
+ readonly brand: unique symbol;
1177
+ }>;
1159
1178
  declare class RefuseDynamicStart extends RefuseDynamicStart_base {
1160
1179
  readonly [DecisionTypeId]: symbol;
1161
1180
  }
1162
1181
  declare const SupervisionDecision: Schema.Union<readonly [typeof Stale, typeof Continue, typeof RestartChildren, typeof StartChildren, typeof CoolDown, typeof StopChildren, typeof Terminate, typeof RefuseDynamicStart]>;
1163
1182
  type SupervisionDecision = typeof SupervisionDecision.Type;
1164
- //#endregion
1165
- //#region src/kernel/SupervisionEvent.schema.d.ts
1166
1183
  declare const SupervisionEvent: Schema.Union<readonly [Schema.TaggedStruct<"SupervisorStarted", {
1167
1184
  readonly at: Schema.Int;
1168
1185
  }>, Schema.TaggedStruct<"ChildStarted", {
@@ -1229,27 +1246,16 @@ declare const SupervisionEvent: Schema.Union<readonly [Schema.TaggedStruct<"Supe
1229
1246
  }>]>;
1230
1247
  }>]>;
1231
1248
  type SupervisionEvent = typeof SupervisionEvent.Type;
1232
- //#endregion
1233
- //#region src/Supervisor/bound-child.d.ts
1234
- /**
1235
- * A child bound to the medium that interprets its program, and to the services
1236
- * that medium needs (KTD9, R15, R17, R18). Every operation already runs in the
1237
- * context the supervisor acquired, so the handle stores one bound child per
1238
- * declared and dynamic child, and the executor never names a medium.
1239
- */
1249
+ interface Incarnation {
1250
+ readonly evidence: Started;
1251
+ readonly scope: Scope.Closeable;
1252
+ }
1240
1253
  interface BoundChild {
1241
- /**
1242
- * Starts one incarnation in a fresh child scope. A medium whose `start` fails
1243
- * produces an abnormal `TerminationReason` instead of a failure, so nothing
1244
- * downstream claims the child started (R15, KTD8).
1245
- */
1246
- readonly start: Effect.Effect<Started, TerminationReason, Scope.Scope>;
1247
- readonly report: (evidence: Started) => Effect.Effect<TerminationReason, never, never>;
1248
- readonly probe: (evidence: Started) => Effect.Effect<boolean, never, never>;
1249
- readonly stop: (evidence: Started, mode: ShutdownMode) => Effect.Effect<Stopped, never, never>;
1254
+ readonly start: Effect.Effect<Incarnation, TerminationReason, Scope.Scope>;
1255
+ readonly report: (incarnation: Incarnation) => Effect.Effect<TerminationReason, never, never>;
1256
+ readonly probe: (incarnation: Incarnation) => Effect.Effect<boolean, never, never>;
1257
+ readonly stop: (incarnation: Incarnation, mode: ShutdownMode) => Effect.Effect<Stopped, never, never>;
1250
1258
  }
1251
- //#endregion
1252
- //#region src/Supervisor/DynamicOutcome.schema.d.ts
1253
1259
  declare const DynamicStartAccepted: Schema.Struct<{
1254
1260
  readonly outcome: Schema.Literal<"accepted">;
1255
1261
  readonly childId: Schema.String;
@@ -1294,8 +1300,6 @@ declare const DynamicOutcome: Schema.Union<readonly [Schema.Union<readonly [Sche
1294
1300
  readonly outcome: Schema.Literal<"missed">;
1295
1301
  }>]>]>;
1296
1302
  type DynamicOutcome = typeof DynamicOutcome.Type;
1297
- //#endregion
1298
- //#region src/Supervisor/running-supervisor.handle.d.ts
1299
1303
  /** Brands a running supervisor handle. */
1300
1304
  declare const TypeId: unique symbol;
1301
1305
  /** The running supervisor brand. */
@@ -1309,7 +1313,7 @@ interface SupervisorSlot {
1309
1313
  readonly state: Ref.Ref<SupervisorState>;
1310
1314
  readonly mailbox: Queue.Queue<SupervisionEvent>;
1311
1315
  readonly trace: PubSub.PubSub<TraceEntry>;
1312
- readonly evidence: Ref.Ref<HashMap.HashMap<string, Started>>;
1316
+ readonly evidence: Ref.Ref<HashMap.HashMap<string, Incarnation>>;
1313
1317
  readonly replies: Ref.Ref<HashMap.HashMap<string, Deferred.Deferred<DynamicOutcome>>>;
1314
1318
  readonly boundChildren: Ref.Ref<HashMap.HashMap<ChildId, BoundChild>>;
1315
1319
  readonly pending: Ref.Ref<HashMap.HashMap<string, BoundChild>>;
@@ -1361,8 +1365,6 @@ declare const stopChild: {
1361
1365
  (childId: ChildId, generation: Generation): (self: RunningSupervisor) => Effect.Effect<DynamicOutcome, SupervisorTerminated>;
1362
1366
  (self: RunningSupervisor, childId: ChildId, generation: Generation): Effect.Effect<DynamicOutcome, SupervisorTerminated>;
1363
1367
  };
1364
- //#endregion
1365
- //#region src/Supervisor/Supervisor.d.ts
1366
1368
  declare const SpecTypeId: unique symbol;
1367
1369
  type SpecTypeId = typeof SpecTypeId;
1368
1370
  /** A fiber-hosted child: a bare effect, a function of `ready`, or a nested spec. */
@@ -1467,5 +1469,4 @@ declare const child: {
1467
1469
  declare namespace mod_d_exports {
1468
1470
  export { BareFiberProgram, ChildOptions, ChildProgram, ChildSpec, ChildSpecs, ClassifyChildExit, DynamicOptions, DynamicOutcome, DynamicStartAccepted, DynamicStartOutcome, DynamicStartRefused, DynamicStopDone, DynamicStopMissed, DynamicStopOutcome, FiberChild, FiberMedium_d_exports as FiberMedium, FiberProgram, Medium_d_exports as Medium, RunningSupervisor, SpecTypeId, SupervisorSpec, SupervisorTerminated, TraceEntry, TypeId, autoShutdown, awaitTerminated, backoff, child, children, classifyChildExit, coolDown, dynamic, intensity, isRunningSupervisor, isSupervisorSpec, livenessTick, make, readyOnStart, shutdown, startChild, statusOf, stopChild, strategy, traceOf };
1469
1471
  }
1470
- //#endregion
1471
1472
  export { mod_d_exports as Supervisor };