reactor-effect-client 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +20 -2
  2. package/dist/_internal/queue.d.ts +6 -0
  3. package/dist/_internal/queue.d.ts.map +1 -0
  4. package/dist/_internal/queue.js +30 -0
  5. package/dist/_internal/queue.js.map +1 -0
  6. package/dist/duration.d.ts +2 -0
  7. package/dist/duration.d.ts.map +1 -1
  8. package/dist/duration.js +1 -1
  9. package/dist/duration.js.map +1 -1
  10. package/dist/host.d.ts +1 -0
  11. package/dist/host.d.ts.map +1 -1
  12. package/dist/host.js +1 -0
  13. package/dist/host.js.map +1 -1
  14. package/dist/observation.d.ts +3 -0
  15. package/dist/observation.d.ts.map +1 -1
  16. package/dist/observation.js +9 -4
  17. package/dist/observation.js.map +1 -1
  18. package/dist/orchestration/h3-source.d.ts.map +1 -1
  19. package/dist/orchestration/h3-source.js +28 -9
  20. package/dist/orchestration/h3-source.js.map +1 -1
  21. package/dist/orchestration/index.d.ts +6 -6
  22. package/dist/orchestration/index.d.ts.map +1 -1
  23. package/dist/orchestration/index.js +3 -3
  24. package/dist/orchestration/index.js.map +1 -1
  25. package/dist/orchestration/media-buffer.d.ts +2 -1
  26. package/dist/orchestration/media-buffer.d.ts.map +1 -1
  27. package/dist/orchestration/media-buffer.js +5 -4
  28. package/dist/orchestration/media-buffer.js.map +1 -1
  29. package/dist/orchestration/queries.d.ts.map +1 -1
  30. package/dist/orchestration/queries.js +3 -0
  31. package/dist/orchestration/queries.js.map +1 -1
  32. package/dist/orchestration/renewal-state.d.ts +28 -4
  33. package/dist/orchestration/renewal-state.d.ts.map +1 -1
  34. package/dist/orchestration/renewal-state.js +42 -7
  35. package/dist/orchestration/renewal-state.js.map +1 -1
  36. package/dist/orchestration/renewal.d.ts +39 -3
  37. package/dist/orchestration/renewal.d.ts.map +1 -1
  38. package/dist/orchestration/renewal.js +490 -103
  39. package/dist/orchestration/renewal.js.map +1 -1
  40. package/dist/orchestration/retention.d.ts +100 -0
  41. package/dist/orchestration/retention.d.ts.map +1 -0
  42. package/dist/orchestration/retention.js +134 -0
  43. package/dist/orchestration/retention.js.map +1 -0
  44. package/dist/orchestration/scheduler-key.d.ts +13 -0
  45. package/dist/orchestration/scheduler-key.d.ts.map +1 -0
  46. package/dist/orchestration/scheduler-key.js +62 -0
  47. package/dist/orchestration/scheduler-key.js.map +1 -0
  48. package/dist/orchestration/scheduler-policy.d.ts +81 -0
  49. package/dist/orchestration/scheduler-policy.d.ts.map +1 -0
  50. package/dist/orchestration/scheduler-policy.js +200 -0
  51. package/dist/orchestration/scheduler-policy.js.map +1 -0
  52. package/dist/orchestration/scheduler.d.ts +184 -0
  53. package/dist/orchestration/scheduler.d.ts.map +1 -0
  54. package/dist/orchestration/scheduler.js +1680 -0
  55. package/dist/orchestration/scheduler.js.map +1 -0
  56. package/dist/orchestration/source-slot.d.ts +20 -5
  57. package/dist/orchestration/source-slot.d.ts.map +1 -1
  58. package/dist/orchestration/source-slot.js +151 -29
  59. package/dist/orchestration/source-slot.js.map +1 -1
  60. package/dist/orchestration/types.d.ts +545 -6
  61. package/dist/orchestration/types.d.ts.map +1 -1
  62. package/dist/orchestration/types.js +105 -1
  63. package/dist/orchestration/types.js.map +1 -1
  64. package/dist/session.d.ts.map +1 -1
  65. package/dist/session.js +2 -1
  66. package/dist/session.js.map +1 -1
  67. package/dist/simulation/_internal/source.d.ts.map +1 -1
  68. package/dist/simulation/_internal/source.js +43 -31
  69. package/dist/simulation/_internal/source.js.map +1 -1
  70. package/package.json +2 -2
  71. package/dist/orchestration/lineup.d.ts +0 -109
  72. package/dist/orchestration/lineup.d.ts.map +0 -1
  73. package/dist/orchestration/lineup.js +0 -249
  74. package/dist/orchestration/lineup.js.map +0 -1
@@ -3,7 +3,7 @@ import * as Data from "effect/Data";
3
3
  import type * as Duration from "effect/Duration";
4
4
  import type * as Effect from "effect/Effect";
5
5
  import type * as Option from "effect/Option";
6
- import type * as Result from "effect/Result";
6
+ import * as Result from "effect/Result";
7
7
  import * as Schema from "effect/Schema";
8
8
  import type * as Scope from "effect/Scope";
9
9
  import type * as Stream from "effect/Stream";
@@ -67,6 +67,8 @@ export declare const BuildTiming: {
67
67
  /** A provider clip is visible even when this application never submitted it. */
68
68
  export interface ClipRecord {
69
69
  readonly clipId: ClipId;
70
+ /** Physical session that owns this clip, including during a renewal overlap. */
71
+ readonly sessionId: string;
70
72
  readonly durationSeconds: number;
71
73
  readonly provider: Clip;
72
74
  readonly request?: ClipRequest;
@@ -91,9 +93,26 @@ export interface Playback {
91
93
  * monotonic clock instead.
92
94
  */
93
95
  readonly startedAt: Option.Option<number>;
96
+ /** Monotonic start observation, available only when this process saw Started. */
97
+ readonly startedAtMonotonicMillis?: number;
94
98
  }
95
99
  export interface EngineState {
96
100
  readonly availability: "Ready" | "Synchronizing" | "Unavailable";
101
+ /** Every live physical source, including one with no clips yet. */
102
+ readonly sessions: readonly {
103
+ readonly sessionId: string;
104
+ readonly availability: EngineState["availability"];
105
+ }[];
106
+ /** The source that receives an unconstrained new request. */
107
+ readonly preferredSessionId: Option.Option<string>;
108
+ /** The source draining ahead of a ready replacement, if there is one. */
109
+ readonly retiringSessionId: Option.Option<string>;
110
+ /**
111
+ * The retiring source can hand off once idle: no sequence holds it
112
+ * preferred, it is not recovering, and its media cannot hold the switch past
113
+ * the final clip's grace. Absent on physical sources.
114
+ */
115
+ readonly handoffReady?: boolean;
97
116
  readonly queued: readonly ClipRecord[];
98
117
  /** Provider queue order, including an independently observed active build. */
99
118
  readonly generationOrder: readonly ClipId[];
@@ -132,10 +151,15 @@ export type EngineEvent = {
132
151
  readonly durationSeconds: number;
133
152
  /** Epoch milliseconds of the local observation, as every event's `at` is. */
134
153
  readonly at: number;
154
+ /** Monotonic instant captured with `at`, for elapsed as-run accounting. */
155
+ readonly atMonotonicMillis?: number;
135
156
  } | {
136
157
  readonly _tag: "Ended";
137
158
  readonly clipId: ClipId;
138
159
  readonly termination: "finished" | "stopped";
160
+ /** Local observation time of the end, when the source provides it. */
161
+ readonly at?: number;
162
+ readonly atMonotonicMillis?: number;
139
163
  } | {
140
164
  readonly _tag: "Failed";
141
165
  readonly clipId: ClipId;
@@ -144,12 +168,21 @@ export type EngineEvent = {
144
168
  } | {
145
169
  readonly _tag: "Starved";
146
170
  readonly at: number;
171
+ }
172
+ /**
173
+ * The retiring source's final clip arrived in full while a replacement is
174
+ * Ready. An observation only: a short clip still switches once its grace
175
+ * past Ended elapses, without this event.
176
+ */
177
+ | {
178
+ readonly _tag: "HandoffReady";
179
+ readonly sessionId: string;
147
180
  } | {
148
181
  readonly _tag: "SessionFailed";
149
182
  readonly failure: ReactorFailure;
150
183
  };
151
184
  export declare const EngineEvent: {
152
- readonly $is: <Tag extends "Building" | "Ended" | "Failed" | "Queued" | "Ready" | "SessionFailed" | "Started" | "Starved">(tag: Tag) => (u: unknown) => u is Extract<{
185
+ readonly $is: <Tag extends "Building" | "Ended" | "Failed" | "HandoffReady" | "Queued" | "Ready" | "SessionFailed" | "Started" | "Starved">(tag: Tag) => (u: unknown) => u is Extract<{
153
186
  readonly _tag: "Queued";
154
187
  readonly clipId: ClipId;
155
188
  readonly durationSeconds: number;
@@ -174,12 +207,17 @@ export declare const EngineEvent: {
174
207
  readonly durationSeconds: number;
175
208
  /** Epoch milliseconds of the local observation, as every event's `at` is. */
176
209
  readonly at: number;
210
+ /** Monotonic instant captured with `at`, for elapsed as-run accounting. */
211
+ readonly atMonotonicMillis?: number;
177
212
  }, {
178
213
  readonly _tag: Tag;
179
214
  }> | Extract<{
180
215
  readonly _tag: "Ended";
181
216
  readonly clipId: ClipId;
182
217
  readonly termination: "finished" | "stopped";
218
+ /** Local observation time of the end, when the source provides it. */
219
+ readonly at?: number;
220
+ readonly atMonotonicMillis?: number;
183
221
  }, {
184
222
  readonly _tag: Tag;
185
223
  }> | Extract<{
@@ -194,6 +232,11 @@ export declare const EngineEvent: {
194
232
  readonly at: number;
195
233
  }, {
196
234
  readonly _tag: Tag;
235
+ }> | Extract<{
236
+ readonly _tag: "HandoffReady";
237
+ readonly sessionId: string;
238
+ }, {
239
+ readonly _tag: Tag;
197
240
  }> | Extract<{
198
241
  readonly _tag: "SessionFailed";
199
242
  readonly failure: ReactorFailure;
@@ -201,12 +244,12 @@ export declare const EngineEvent: {
201
244
  readonly _tag: Tag;
202
245
  }>;
203
246
  readonly $match: {
204
- <Cases extends { readonly [Tag in "Building" | "Ended" | "Failed" | "Queued" | "Ready" | "SessionFailed" | "Started" | "Starved"]: (args: Extract<EngineEvent, {
247
+ <Cases extends { readonly [Tag in "Building" | "Ended" | "Failed" | "HandoffReady" | "Queued" | "Ready" | "SessionFailed" | "Started" | "Starved"]: (args: Extract<EngineEvent, {
205
248
  readonly _tag: Tag;
206
- }>) => any; }>(cases: Cases): (value: EngineEvent) => import("effect/Unify").Unify<ReturnType<Cases["Building" | "Ended" | "Failed" | "Queued" | "Ready" | "SessionFailed" | "Started" | "Starved"]>>;
207
- <Cases extends { readonly [Tag in "Building" | "Ended" | "Failed" | "Queued" | "Ready" | "SessionFailed" | "Started" | "Starved"]: (args: Extract<EngineEvent, {
249
+ }>) => any; }>(cases: Cases): (value: EngineEvent) => import("effect/Unify").Unify<ReturnType<Cases["Building" | "Ended" | "Failed" | "HandoffReady" | "Queued" | "Ready" | "SessionFailed" | "Started" | "Starved"]>>;
250
+ <Cases extends { readonly [Tag in "Building" | "Ended" | "Failed" | "HandoffReady" | "Queued" | "Ready" | "SessionFailed" | "Started" | "Starved"]: (args: Extract<EngineEvent, {
208
251
  readonly _tag: Tag;
209
- }>) => any; }>(value: EngineEvent, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["Building" | "Ended" | "Failed" | "Queued" | "Ready" | "SessionFailed" | "Started" | "Starved"]>>;
252
+ }>) => any; }>(value: EngineEvent, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["Building" | "Ended" | "Failed" | "HandoffReady" | "Queued" | "Ready" | "SessionFailed" | "Started" | "Starved"]>>;
210
253
  };
211
254
  readonly Building: Data.TaggedEnum.ConstructorFrom<{
212
255
  readonly _tag: "Building";
@@ -217,6 +260,9 @@ export declare const EngineEvent: {
217
260
  readonly _tag: "Ended";
218
261
  readonly clipId: ClipId;
219
262
  readonly termination: "finished" | "stopped";
263
+ /** Local observation time of the end, when the source provides it. */
264
+ readonly at?: number;
265
+ readonly atMonotonicMillis?: number;
220
266
  }, "_tag">;
221
267
  readonly Failed: Data.TaggedEnum.ConstructorFrom<{
222
268
  readonly _tag: "Failed";
@@ -224,6 +270,10 @@ export declare const EngineEvent: {
224
270
  readonly reason: string;
225
271
  readonly sessionId?: string;
226
272
  }, "_tag">;
273
+ readonly HandoffReady: Data.TaggedEnum.ConstructorFrom<{
274
+ readonly _tag: "HandoffReady";
275
+ readonly sessionId: string;
276
+ }, "_tag">;
227
277
  readonly Queued: Data.TaggedEnum.ConstructorFrom<{
228
278
  readonly _tag: "Queued";
229
279
  readonly clipId: ClipId;
@@ -245,6 +295,8 @@ export declare const EngineEvent: {
245
295
  readonly durationSeconds: number;
246
296
  /** Epoch milliseconds of the local observation, as every event's `at` is. */
247
297
  readonly at: number;
298
+ /** Monotonic instant captured with `at`, for elapsed as-run accounting. */
299
+ readonly atMonotonicMillis?: number;
248
300
  }, "_tag">;
249
301
  readonly Starved: Data.TaggedEnum.ConstructorFrom<{
250
302
  readonly _tag: "Starved";
@@ -273,6 +325,12 @@ export type ObserveEngine = (options?: ObservationOptions) => Effect.Effect<Engi
273
325
  export interface EngineShape {
274
326
  readonly prepare: (request: ClipRequest) => Effect.Effect<Submission<ClipId, EngineError>, EngineError>;
275
327
  readonly enqueue: (request: ClipRequest) => Effect.Effect<ClipId, EngineError>;
328
+ /** Refuse before dispatch if routing would select another physical source. */
329
+ readonly enqueueOnSource?: ((request: ClipRequest, expectedSessionId: string) => Effect.Effect<ClipId, EngineError>) | undefined;
330
+ /**
331
+ * The current state. After an owned renewal worker's defect or unexpected
332
+ * interruption, it fails with that worker's Cause until close begins.
333
+ */
276
334
  readonly state: Effect.Effect<EngineState>;
277
335
  /** Later events only, subscribed when the stream runs; use `observe` to pair them with a state. */
278
336
  readonly events: Stream.Stream<EngineEvent, ReactorError>;
@@ -280,11 +338,18 @@ export interface EngineShape {
280
338
  /**
281
339
  * The terminal failure, as it was raised: a session's `ReactorError`, a
282
340
  * replacement's `AcquisitionFailure` with its cleanup, or the failed command.
341
+ * An owned renewal worker's defect or unexpected interruption fails this
342
+ * effect and observations with the original Cause instead of a typed error.
343
+ * A waiter that must act on either, such as one that closes the handle,
344
+ * handles the whole Cause (`Effect.catchCause`), not only this value.
283
345
  */
284
346
  readonly failure: Effect.Effect<ReactorFailure>;
347
+ /** Permanently stop new renewal allocations; already acquired sources may finish. */
348
+ readonly stopRenewal: Effect.Effect<void, EngineError>;
285
349
  readonly setAutoplay: (enabled: boolean) => Effect.Effect<void, EngineError>;
286
350
  readonly pauseAndStop: Effect.Effect<void, EngineError>;
287
351
  readonly remove: (id: ClipId) => Effect.Effect<RemoveOutcome, EngineError>;
352
+ /** A global rank within this clip's physical session range in the chosen queue. */
288
353
  readonly move: (id: ClipId, position: number, queue: "generation" | "playout") => Effect.Effect<void, EngineError>;
289
354
  readonly setCanvas: (canvas: Canvas) => Effect.Effect<void, EngineError>;
290
355
  }
@@ -372,6 +437,29 @@ export type Renewal = {
372
437
  readonly sessionId: string;
373
438
  readonly ageSeconds: number;
374
439
  readonly tail: MediaTail;
440
+ /** Eligibility facts captured before retirement waits; absent on historical event values. */
441
+ readonly handoff?: {
442
+ readonly replacementSessionId: string;
443
+ readonly decision: "no-observed-start" | "count-complete" | "grace-elapsed";
444
+ /** Local decoded-frame accounting, not presentation or audio completeness. */
445
+ readonly finalClip: {
446
+ readonly _tag: "NoObservedStart";
447
+ } | {
448
+ readonly _tag: "Observed";
449
+ readonly clipId: ClipId;
450
+ readonly expectedVideoFrames: number;
451
+ readonly receivedVideoFrames: number;
452
+ readonly videoStatus: "count-complete" | "incomplete";
453
+ };
454
+ readonly grace: {
455
+ readonly _tag: "NotObserved";
456
+ } | {
457
+ readonly _tag: "Observed";
458
+ readonly origin: "Ended" | "Idle";
459
+ readonly elapsedMs: number;
460
+ readonly limitMs: number;
461
+ };
462
+ };
375
463
  } | {
376
464
  readonly _tag: "Replaced";
377
465
  readonly reason: string;
@@ -848,6 +936,451 @@ export declare const CleanupReport: Schema.Struct<{
848
936
  }>;
849
937
  export interface CleanupReport extends Schema.Schema.Type<typeof CleanupReport> {
850
938
  }
939
+ /** The facts that decide whether a retirement is proven complete. */
940
+ interface RetirementEvidence {
941
+ readonly source?: {
942
+ readonly sessionId: string;
943
+ } | undefined;
944
+ readonly cleanup?: SourceCleanup | undefined;
945
+ readonly conflictingCleanup?: SourceCleanup | undefined;
946
+ readonly retirement: {
947
+ readonly accounting: "settled" | "timed-out" | "not-applicable";
948
+ readonly scope: "closed" | "failed";
949
+ readonly affinity: "retired" | "failed" | "not-applicable";
950
+ readonly errors: readonly unknown[];
951
+ readonly unknownSubmissions: bigint;
952
+ };
953
+ }
954
+ /**
955
+ * The omitted-complete counter a proven complete retirement belongs to, or
956
+ * undefined when its evidence is incomplete. The retention owner classifies
957
+ * with it and the summary codec checks rows marked complete against it, so
958
+ * decoded evidence cannot present an incomplete retirement as compacted.
959
+ */
960
+ export declare const completeKind: (evidence: RetirementEvidence) => "noAllocation" | "ownedTerminated" | "attachedDetached" | undefined;
961
+ /**
962
+ * Continuous cleanup is explicitly summarized. The absence of `sessions` makes
963
+ * legacy complete-history decoders reject it instead of accepting truncated evidence.
964
+ * JSON codecs encode its exact counts and ordinals as decimal strings.
965
+ */
966
+ export declare const CleanupSummary: Schema.Struct<{
967
+ readonly format: Schema.Literal<"reactor-orchestration-cleanup-summary/v1">;
968
+ readonly totalRetirements: Schema.BigInt;
969
+ readonly omittedComplete: Schema.Struct<{
970
+ readonly noAllocation: Schema.BigInt;
971
+ readonly ownedTerminated: Schema.BigInt;
972
+ readonly attachedDetached: Schema.BigInt;
973
+ }>;
974
+ readonly retained: Schema.$Array<Schema.Struct<{
975
+ readonly ordinal: Schema.BigInt;
976
+ readonly source: Schema.optionalKey<Schema.Struct<{
977
+ readonly sessionId: Schema.String;
978
+ readonly incarnation: Schema.BigInt;
979
+ }>>;
980
+ readonly cleanup: Schema.optionalKey<Schema.Struct<{
981
+ /** The unmodified lifecycle owner's canonical cleanup evidence. */
982
+ readonly lease: Schema.Struct<{
983
+ readonly localClosed: Schema.Boolean;
984
+ readonly allocation: Schema.Literals<readonly ["none", "known", "unknown"]>;
985
+ readonly ownership: Schema.optionalKey<Schema.Literals<readonly ["owned", "attached"]>>;
986
+ readonly sessionId: Schema.optionalKey<Schema.String>;
987
+ readonly remote: Schema.Struct<{
988
+ readonly attempted: Schema.Boolean;
989
+ readonly responseReceived: Schema.Boolean;
990
+ readonly confirmed: Schema.Boolean;
991
+ readonly evidence: Schema.NullOr<Schema.Literals<readonly ["absent", "terminal"]>>;
992
+ readonly deleteStatus: Schema.NullOr<Schema.Int>;
993
+ readonly state: Schema.NullOr<Schema.String>;
994
+ readonly error: Schema.optionalKey<Schema.decodeTo<Schema.declare<ReactorError, ReactorError>, Schema.Codec<{
995
+ readonly _tag: "ReactorError";
996
+ readonly message: string;
997
+ readonly reason: {
998
+ readonly _tag: "Aborted" | "AlreadyReading" | "ChannelClosed" | "Closed" | "Disconnected" | "Indeterminate" | "InvalidInput" | "InvalidState" | "Overflow" | "Protocol" | "SdpRejected" | "Shutdown" | "TerminalSession" | "Timeout" | "UnexpectedReply" | "UnsupportedCapability" | "UnsupportedHost" | "Upload" | "VersionMismatch";
999
+ readonly message: string;
1000
+ } | {
1001
+ readonly _tag: "Http";
1002
+ readonly message: string;
1003
+ readonly status?: number;
1004
+ readonly retryAfterMillis?: number;
1005
+ } | {
1006
+ readonly _tag: "RecorderDisabled" | "Remote";
1007
+ readonly message: string;
1008
+ readonly remoteCode?: string;
1009
+ } | {
1010
+ readonly _tag: "Native";
1011
+ readonly message: string;
1012
+ readonly status?: number;
1013
+ } | {
1014
+ readonly _tag: "IceFailed";
1015
+ readonly message: string;
1016
+ readonly pairs: number;
1017
+ readonly candidateTypes: readonly string[];
1018
+ } | {
1019
+ readonly _tag: "TransportFailed";
1020
+ readonly message: string;
1021
+ readonly pairs: number;
1022
+ } | {
1023
+ readonly _tag: "ClipEnded";
1024
+ readonly message: string;
1025
+ readonly clipId: string;
1026
+ readonly lifecycle: "clip_failed" | "clip_popped";
1027
+ readonly transportGeneration: string;
1028
+ };
1029
+ readonly context: {
1030
+ readonly operation?: string;
1031
+ readonly requestId?: string;
1032
+ readonly sessionId?: string;
1033
+ readonly generation?: string;
1034
+ readonly outcome?: "not-submitted" | "replied" | "unknown";
1035
+ };
1036
+ }, unknown, never, never>, never, never>>;
1037
+ }>;
1038
+ readonly unpublishSubmitted: Schema.$Array<Schema.String>;
1039
+ readonly unresolvedPublications: Schema.$Array<Schema.String>;
1040
+ readonly localErrors: Schema.$Array<Schema.decodeTo<Schema.declare<ReactorError, ReactorError>, Schema.Codec<{
1041
+ readonly _tag: "ReactorError";
1042
+ readonly message: string;
1043
+ readonly reason: {
1044
+ readonly _tag: "Aborted" | "AlreadyReading" | "ChannelClosed" | "Closed" | "Disconnected" | "Indeterminate" | "InvalidInput" | "InvalidState" | "Overflow" | "Protocol" | "SdpRejected" | "Shutdown" | "TerminalSession" | "Timeout" | "UnexpectedReply" | "UnsupportedCapability" | "UnsupportedHost" | "Upload" | "VersionMismatch";
1045
+ readonly message: string;
1046
+ } | {
1047
+ readonly _tag: "Http";
1048
+ readonly message: string;
1049
+ readonly status?: number;
1050
+ readonly retryAfterMillis?: number;
1051
+ } | {
1052
+ readonly _tag: "RecorderDisabled" | "Remote";
1053
+ readonly message: string;
1054
+ readonly remoteCode?: string;
1055
+ } | {
1056
+ readonly _tag: "Native";
1057
+ readonly message: string;
1058
+ readonly status?: number;
1059
+ } | {
1060
+ readonly _tag: "IceFailed";
1061
+ readonly message: string;
1062
+ readonly pairs: number;
1063
+ readonly candidateTypes: readonly string[];
1064
+ } | {
1065
+ readonly _tag: "TransportFailed";
1066
+ readonly message: string;
1067
+ readonly pairs: number;
1068
+ } | {
1069
+ readonly _tag: "ClipEnded";
1070
+ readonly message: string;
1071
+ readonly clipId: string;
1072
+ readonly lifecycle: "clip_failed" | "clip_popped";
1073
+ readonly transportGeneration: string;
1074
+ };
1075
+ readonly context: {
1076
+ readonly operation?: string;
1077
+ readonly requestId?: string;
1078
+ readonly sessionId?: string;
1079
+ readonly generation?: string;
1080
+ readonly outcome?: "not-submitted" | "replied" | "unknown";
1081
+ };
1082
+ }, unknown, never, never>, never, never>>;
1083
+ }>;
1084
+ readonly policy: Schema.$Array<Schema.Struct<{
1085
+ readonly operation: Schema.String;
1086
+ readonly result: Schema.Result<Schema.Void, Schema.Union<readonly [Schema.decodeTo<Schema.declare<CommandFailure, CommandFailure>, Schema.Codec<{
1087
+ readonly _tag: "CommandFailure";
1088
+ readonly message: string;
1089
+ readonly reason: {
1090
+ readonly _tag: "Aborted" | "AlreadyReading" | "ChannelClosed" | "Closed" | "Disconnected" | "Indeterminate" | "InvalidInput" | "InvalidState" | "Overflow" | "Protocol" | "SdpRejected" | "Shutdown" | "TerminalSession" | "Timeout" | "UnexpectedReply" | "UnsupportedCapability" | "UnsupportedHost" | "Upload" | "VersionMismatch";
1091
+ readonly message: string;
1092
+ } | {
1093
+ readonly _tag: "Http";
1094
+ readonly message: string;
1095
+ readonly status?: number;
1096
+ readonly retryAfterMillis?: number;
1097
+ } | {
1098
+ readonly _tag: "RecorderDisabled" | "Remote";
1099
+ readonly message: string;
1100
+ readonly remoteCode?: string;
1101
+ } | {
1102
+ readonly _tag: "Native";
1103
+ readonly message: string;
1104
+ readonly status?: number;
1105
+ } | {
1106
+ readonly _tag: "IceFailed";
1107
+ readonly message: string;
1108
+ readonly pairs: number;
1109
+ readonly candidateTypes: readonly string[];
1110
+ } | {
1111
+ readonly _tag: "TransportFailed";
1112
+ readonly message: string;
1113
+ readonly pairs: number;
1114
+ } | {
1115
+ readonly _tag: "ClipEnded";
1116
+ readonly message: string;
1117
+ readonly clipId: string;
1118
+ readonly lifecycle: "clip_failed" | "clip_popped";
1119
+ readonly transportGeneration: string;
1120
+ };
1121
+ readonly context: {
1122
+ readonly operation?: string;
1123
+ readonly requestId?: string;
1124
+ readonly sessionId?: string;
1125
+ readonly generation?: string;
1126
+ readonly outcome?: "not-submitted" | "replied" | "unknown";
1127
+ };
1128
+ }, unknown, never, never>, never, never>, Schema.decodeTo<Schema.declare<PolicyFailure, PolicyFailure>, Schema.Codec<{
1129
+ readonly _tag: "PolicyFailure";
1130
+ readonly message: string;
1131
+ readonly reason: {
1132
+ readonly _tag: "AnchorUnavailable" | "AnnotationCapacity" | "Busy" | "ContinuationUnavailable" | "IdentityExhausted" | "InvalidRequest" | "NotFound" | "OwnerConflict" | "PositionConflict" | "QueueChanged" | "QueueFull" | "RouteChanged" | "SessionClosed" | "SessionRecovering" | "SessionRetired" | "SubmissionCapacity";
1133
+ readonly message: string;
1134
+ } | {
1135
+ readonly _tag: "Missing";
1136
+ readonly message: string;
1137
+ readonly purpose: "anchor" | "continuation" | "session_anchor";
1138
+ } | {
1139
+ readonly _tag: "Sequence";
1140
+ readonly message: string;
1141
+ readonly sequenceId: string;
1142
+ readonly code: "capacity" | "indeterminate" | "member-capacity" | "member-duplicate" | "member-missing" | "missing" | "not-releasable" | "owner-mismatch" | "retired" | "sealed" | "sealing";
1143
+ };
1144
+ readonly context: {
1145
+ readonly operation?: string;
1146
+ readonly requestId?: string;
1147
+ readonly sessionId?: string;
1148
+ readonly generation?: string;
1149
+ readonly outcome?: "not-submitted" | "replied" | "unknown";
1150
+ };
1151
+ }, unknown, never, never>, never, never>]>>;
1152
+ }>>;
1153
+ }>>;
1154
+ readonly conflictingCleanup: Schema.optionalKey<Schema.Struct<{
1155
+ /** The unmodified lifecycle owner's canonical cleanup evidence. */
1156
+ readonly lease: Schema.Struct<{
1157
+ readonly localClosed: Schema.Boolean;
1158
+ readonly allocation: Schema.Literals<readonly ["none", "known", "unknown"]>;
1159
+ readonly ownership: Schema.optionalKey<Schema.Literals<readonly ["owned", "attached"]>>;
1160
+ readonly sessionId: Schema.optionalKey<Schema.String>;
1161
+ readonly remote: Schema.Struct<{
1162
+ readonly attempted: Schema.Boolean;
1163
+ readonly responseReceived: Schema.Boolean;
1164
+ readonly confirmed: Schema.Boolean;
1165
+ readonly evidence: Schema.NullOr<Schema.Literals<readonly ["absent", "terminal"]>>;
1166
+ readonly deleteStatus: Schema.NullOr<Schema.Int>;
1167
+ readonly state: Schema.NullOr<Schema.String>;
1168
+ readonly error: Schema.optionalKey<Schema.decodeTo<Schema.declare<ReactorError, ReactorError>, Schema.Codec<{
1169
+ readonly _tag: "ReactorError";
1170
+ readonly message: string;
1171
+ readonly reason: {
1172
+ readonly _tag: "Aborted" | "AlreadyReading" | "ChannelClosed" | "Closed" | "Disconnected" | "Indeterminate" | "InvalidInput" | "InvalidState" | "Overflow" | "Protocol" | "SdpRejected" | "Shutdown" | "TerminalSession" | "Timeout" | "UnexpectedReply" | "UnsupportedCapability" | "UnsupportedHost" | "Upload" | "VersionMismatch";
1173
+ readonly message: string;
1174
+ } | {
1175
+ readonly _tag: "Http";
1176
+ readonly message: string;
1177
+ readonly status?: number;
1178
+ readonly retryAfterMillis?: number;
1179
+ } | {
1180
+ readonly _tag: "RecorderDisabled" | "Remote";
1181
+ readonly message: string;
1182
+ readonly remoteCode?: string;
1183
+ } | {
1184
+ readonly _tag: "Native";
1185
+ readonly message: string;
1186
+ readonly status?: number;
1187
+ } | {
1188
+ readonly _tag: "IceFailed";
1189
+ readonly message: string;
1190
+ readonly pairs: number;
1191
+ readonly candidateTypes: readonly string[];
1192
+ } | {
1193
+ readonly _tag: "TransportFailed";
1194
+ readonly message: string;
1195
+ readonly pairs: number;
1196
+ } | {
1197
+ readonly _tag: "ClipEnded";
1198
+ readonly message: string;
1199
+ readonly clipId: string;
1200
+ readonly lifecycle: "clip_failed" | "clip_popped";
1201
+ readonly transportGeneration: string;
1202
+ };
1203
+ readonly context: {
1204
+ readonly operation?: string;
1205
+ readonly requestId?: string;
1206
+ readonly sessionId?: string;
1207
+ readonly generation?: string;
1208
+ readonly outcome?: "not-submitted" | "replied" | "unknown";
1209
+ };
1210
+ }, unknown, never, never>, never, never>>;
1211
+ }>;
1212
+ readonly unpublishSubmitted: Schema.$Array<Schema.String>;
1213
+ readonly unresolvedPublications: Schema.$Array<Schema.String>;
1214
+ readonly localErrors: Schema.$Array<Schema.decodeTo<Schema.declare<ReactorError, ReactorError>, Schema.Codec<{
1215
+ readonly _tag: "ReactorError";
1216
+ readonly message: string;
1217
+ readonly reason: {
1218
+ readonly _tag: "Aborted" | "AlreadyReading" | "ChannelClosed" | "Closed" | "Disconnected" | "Indeterminate" | "InvalidInput" | "InvalidState" | "Overflow" | "Protocol" | "SdpRejected" | "Shutdown" | "TerminalSession" | "Timeout" | "UnexpectedReply" | "UnsupportedCapability" | "UnsupportedHost" | "Upload" | "VersionMismatch";
1219
+ readonly message: string;
1220
+ } | {
1221
+ readonly _tag: "Http";
1222
+ readonly message: string;
1223
+ readonly status?: number;
1224
+ readonly retryAfterMillis?: number;
1225
+ } | {
1226
+ readonly _tag: "RecorderDisabled" | "Remote";
1227
+ readonly message: string;
1228
+ readonly remoteCode?: string;
1229
+ } | {
1230
+ readonly _tag: "Native";
1231
+ readonly message: string;
1232
+ readonly status?: number;
1233
+ } | {
1234
+ readonly _tag: "IceFailed";
1235
+ readonly message: string;
1236
+ readonly pairs: number;
1237
+ readonly candidateTypes: readonly string[];
1238
+ } | {
1239
+ readonly _tag: "TransportFailed";
1240
+ readonly message: string;
1241
+ readonly pairs: number;
1242
+ } | {
1243
+ readonly _tag: "ClipEnded";
1244
+ readonly message: string;
1245
+ readonly clipId: string;
1246
+ readonly lifecycle: "clip_failed" | "clip_popped";
1247
+ readonly transportGeneration: string;
1248
+ };
1249
+ readonly context: {
1250
+ readonly operation?: string;
1251
+ readonly requestId?: string;
1252
+ readonly sessionId?: string;
1253
+ readonly generation?: string;
1254
+ readonly outcome?: "not-submitted" | "replied" | "unknown";
1255
+ };
1256
+ }, unknown, never, never>, never, never>>;
1257
+ }>;
1258
+ readonly policy: Schema.$Array<Schema.Struct<{
1259
+ readonly operation: Schema.String;
1260
+ readonly result: Schema.Result<Schema.Void, Schema.Union<readonly [Schema.decodeTo<Schema.declare<CommandFailure, CommandFailure>, Schema.Codec<{
1261
+ readonly _tag: "CommandFailure";
1262
+ readonly message: string;
1263
+ readonly reason: {
1264
+ readonly _tag: "Aborted" | "AlreadyReading" | "ChannelClosed" | "Closed" | "Disconnected" | "Indeterminate" | "InvalidInput" | "InvalidState" | "Overflow" | "Protocol" | "SdpRejected" | "Shutdown" | "TerminalSession" | "Timeout" | "UnexpectedReply" | "UnsupportedCapability" | "UnsupportedHost" | "Upload" | "VersionMismatch";
1265
+ readonly message: string;
1266
+ } | {
1267
+ readonly _tag: "Http";
1268
+ readonly message: string;
1269
+ readonly status?: number;
1270
+ readonly retryAfterMillis?: number;
1271
+ } | {
1272
+ readonly _tag: "RecorderDisabled" | "Remote";
1273
+ readonly message: string;
1274
+ readonly remoteCode?: string;
1275
+ } | {
1276
+ readonly _tag: "Native";
1277
+ readonly message: string;
1278
+ readonly status?: number;
1279
+ } | {
1280
+ readonly _tag: "IceFailed";
1281
+ readonly message: string;
1282
+ readonly pairs: number;
1283
+ readonly candidateTypes: readonly string[];
1284
+ } | {
1285
+ readonly _tag: "TransportFailed";
1286
+ readonly message: string;
1287
+ readonly pairs: number;
1288
+ } | {
1289
+ readonly _tag: "ClipEnded";
1290
+ readonly message: string;
1291
+ readonly clipId: string;
1292
+ readonly lifecycle: "clip_failed" | "clip_popped";
1293
+ readonly transportGeneration: string;
1294
+ };
1295
+ readonly context: {
1296
+ readonly operation?: string;
1297
+ readonly requestId?: string;
1298
+ readonly sessionId?: string;
1299
+ readonly generation?: string;
1300
+ readonly outcome?: "not-submitted" | "replied" | "unknown";
1301
+ };
1302
+ }, unknown, never, never>, never, never>, Schema.decodeTo<Schema.declare<PolicyFailure, PolicyFailure>, Schema.Codec<{
1303
+ readonly _tag: "PolicyFailure";
1304
+ readonly message: string;
1305
+ readonly reason: {
1306
+ readonly _tag: "AnchorUnavailable" | "AnnotationCapacity" | "Busy" | "ContinuationUnavailable" | "IdentityExhausted" | "InvalidRequest" | "NotFound" | "OwnerConflict" | "PositionConflict" | "QueueChanged" | "QueueFull" | "RouteChanged" | "SessionClosed" | "SessionRecovering" | "SessionRetired" | "SubmissionCapacity";
1307
+ readonly message: string;
1308
+ } | {
1309
+ readonly _tag: "Missing";
1310
+ readonly message: string;
1311
+ readonly purpose: "anchor" | "continuation" | "session_anchor";
1312
+ } | {
1313
+ readonly _tag: "Sequence";
1314
+ readonly message: string;
1315
+ readonly sequenceId: string;
1316
+ readonly code: "capacity" | "indeterminate" | "member-capacity" | "member-duplicate" | "member-missing" | "missing" | "not-releasable" | "owner-mismatch" | "retired" | "sealed" | "sealing";
1317
+ };
1318
+ readonly context: {
1319
+ readonly operation?: string;
1320
+ readonly requestId?: string;
1321
+ readonly sessionId?: string;
1322
+ readonly generation?: string;
1323
+ readonly outcome?: "not-submitted" | "replied" | "unknown";
1324
+ };
1325
+ }, unknown, never, never>, never, never>]>>;
1326
+ }>>;
1327
+ }>>;
1328
+ readonly retirement: Schema.Struct<{
1329
+ readonly accounting: Schema.Literals<readonly ["settled", "timed-out", "not-applicable"]>;
1330
+ readonly scope: Schema.Literals<readonly ["closed", "failed"]>;
1331
+ readonly affinity: Schema.Literals<readonly ["retired", "failed", "not-applicable"]>;
1332
+ readonly errors: Schema.$Array<Schema.decodeTo<Schema.declare<ReactorError, ReactorError>, Schema.Codec<{
1333
+ readonly _tag: "ReactorError";
1334
+ readonly message: string;
1335
+ readonly reason: {
1336
+ readonly _tag: "Aborted" | "AlreadyReading" | "ChannelClosed" | "Closed" | "Disconnected" | "Indeterminate" | "InvalidInput" | "InvalidState" | "Overflow" | "Protocol" | "SdpRejected" | "Shutdown" | "TerminalSession" | "Timeout" | "UnexpectedReply" | "UnsupportedCapability" | "UnsupportedHost" | "Upload" | "VersionMismatch";
1337
+ readonly message: string;
1338
+ } | {
1339
+ readonly _tag: "Http";
1340
+ readonly message: string;
1341
+ readonly status?: number;
1342
+ readonly retryAfterMillis?: number;
1343
+ } | {
1344
+ readonly _tag: "RecorderDisabled" | "Remote";
1345
+ readonly message: string;
1346
+ readonly remoteCode?: string;
1347
+ } | {
1348
+ readonly _tag: "Native";
1349
+ readonly message: string;
1350
+ readonly status?: number;
1351
+ } | {
1352
+ readonly _tag: "IceFailed";
1353
+ readonly message: string;
1354
+ readonly pairs: number;
1355
+ readonly candidateTypes: readonly string[];
1356
+ } | {
1357
+ readonly _tag: "TransportFailed";
1358
+ readonly message: string;
1359
+ readonly pairs: number;
1360
+ } | {
1361
+ readonly _tag: "ClipEnded";
1362
+ readonly message: string;
1363
+ readonly clipId: string;
1364
+ readonly lifecycle: "clip_failed" | "clip_popped";
1365
+ readonly transportGeneration: string;
1366
+ };
1367
+ readonly context: {
1368
+ readonly operation?: string;
1369
+ readonly requestId?: string;
1370
+ readonly sessionId?: string;
1371
+ readonly generation?: string;
1372
+ readonly outcome?: "not-submitted" | "replied" | "unknown";
1373
+ };
1374
+ }, unknown, never, never>, never, never>>;
1375
+ /** Settled bookkeeping can still record an unknown dispatch outcome. */
1376
+ readonly unknownSubmissions: Schema.BigInt;
1377
+ }>;
1378
+ readonly disposition: Schema.Literals<readonly ["complete", "incomplete"]>;
1379
+ }>>;
1380
+ readonly exhausted: Schema.Boolean;
1381
+ }>;
1382
+ export interface CleanupSummary extends Schema.Schema.Type<typeof CleanupSummary> {
1383
+ }
851
1384
  /** Resolved by the one router; the full request remains a local annotation. */
852
1385
  export interface RoutedRequest {
853
1386
  readonly request: ClipRequest;
@@ -880,6 +1413,7 @@ export interface Source {
880
1413
  export interface HandleShape {
881
1414
  readonly engine: EngineShape;
882
1415
  readonly media: MediaShape;
1416
+ /** The current media state; like `engine.state`, it fails with a renewal worker's Cause until close begins. */
883
1417
  readonly mediaState: Effect.Effect<MediaState>;
884
1418
  /** Engine, renewal and media changes in one ordered stream, after the current state. */
885
1419
  readonly observe: (options?: ObservationOptions) => Effect.Effect<HandleObservation, ReactorError, Scope.Scope>;
@@ -888,6 +1422,11 @@ export interface HandleShape {
888
1422
  readonly cleanup: Effect.Effect<Option.Option<CleanupReport>>;
889
1423
  readonly sequences: Pick<Affinity<string>, "get" | "snapshots" | "seal" | "acknowledgeIndeterminate" | "release">;
890
1424
  }
1425
+ /** Opt-in continuous renewal retains bounded cleanup evidence in a distinct report. */
1426
+ export interface ContinuousHandleShape extends Omit<HandleShape, "close" | "cleanup"> {
1427
+ readonly close: Effect.Effect<CleanupSummary>;
1428
+ readonly cleanup: Effect.Effect<Option.Option<CleanupSummary>>;
1429
+ }
891
1430
  declare const Engine_base: Context.ServiceClass<Engine, "reactor-effect-client/Orchestration/Engine", EngineShape>;
892
1431
  export declare class Engine extends Engine_base {
893
1432
  }