reactor-effect-client 0.5.0 → 0.7.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 (60) hide show
  1. package/README.md +29 -3
  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/host.d.ts +1 -0
  7. package/dist/host.d.ts.map +1 -1
  8. package/dist/host.js +1 -0
  9. package/dist/host.js.map +1 -1
  10. package/dist/observation.d.ts +3 -0
  11. package/dist/observation.d.ts.map +1 -1
  12. package/dist/observation.js +9 -4
  13. package/dist/observation.js.map +1 -1
  14. package/dist/orchestration/index.d.ts +6 -6
  15. package/dist/orchestration/index.d.ts.map +1 -1
  16. package/dist/orchestration/index.js +3 -3
  17. package/dist/orchestration/index.js.map +1 -1
  18. package/dist/orchestration/media-buffer.d.ts +2 -1
  19. package/dist/orchestration/media-buffer.d.ts.map +1 -1
  20. package/dist/orchestration/media-buffer.js +5 -4
  21. package/dist/orchestration/media-buffer.js.map +1 -1
  22. package/dist/orchestration/renewal-state.d.ts +14 -2
  23. package/dist/orchestration/renewal-state.d.ts.map +1 -1
  24. package/dist/orchestration/renewal-state.js +34 -4
  25. package/dist/orchestration/renewal-state.js.map +1 -1
  26. package/dist/orchestration/renewal.d.ts +27 -3
  27. package/dist/orchestration/renewal.d.ts.map +1 -1
  28. package/dist/orchestration/renewal.js +400 -95
  29. package/dist/orchestration/renewal.js.map +1 -1
  30. package/dist/orchestration/retention.d.ts +100 -0
  31. package/dist/orchestration/retention.d.ts.map +1 -0
  32. package/dist/orchestration/retention.js +134 -0
  33. package/dist/orchestration/retention.js.map +1 -0
  34. package/dist/orchestration/scheduler-key.d.ts +2 -1
  35. package/dist/orchestration/scheduler-key.d.ts.map +1 -1
  36. package/dist/orchestration/scheduler-key.js +2 -2
  37. package/dist/orchestration/scheduler-key.js.map +1 -1
  38. package/dist/orchestration/scheduler-policy.d.ts +153 -12
  39. package/dist/orchestration/scheduler-policy.d.ts.map +1 -1
  40. package/dist/orchestration/scheduler-policy.js +433 -54
  41. package/dist/orchestration/scheduler-policy.js.map +1 -1
  42. package/dist/orchestration/scheduler.d.ts +206 -5
  43. package/dist/orchestration/scheduler.d.ts.map +1 -1
  44. package/dist/orchestration/scheduler.js +1451 -284
  45. package/dist/orchestration/scheduler.js.map +1 -1
  46. package/dist/orchestration/source-slot.d.ts +16 -4
  47. package/dist/orchestration/source-slot.d.ts.map +1 -1
  48. package/dist/orchestration/source-slot.js +122 -30
  49. package/dist/orchestration/source-slot.js.map +1 -1
  50. package/dist/orchestration/types.d.ts +503 -1
  51. package/dist/orchestration/types.d.ts.map +1 -1
  52. package/dist/orchestration/types.js +105 -1
  53. package/dist/orchestration/types.js.map +1 -1
  54. package/dist/session.d.ts.map +1 -1
  55. package/dist/session.js +2 -1
  56. package/dist/session.js.map +1 -1
  57. package/dist/simulation/_internal/source.d.ts.map +1 -1
  58. package/dist/simulation/_internal/source.js +5 -4
  59. package/dist/simulation/_internal/source.js.map +1 -1
  60. package/package.json +2 -2
package/README.md CHANGED
@@ -160,13 +160,39 @@ The adapter exposes autoplay, flush, playback, reset, and other model controls a
160
160
 
161
161
  `reactor-effect-client/orchestration` owns opt-in scheduling, sequence routing, renewal, and recovering media. `fromH3Session(session, options)` builds a physical source from one connected session, deriving its H3 provider view (exposed as `source.provider`) and its decoded media from that session, so a source cannot pair one session's commands with another's media; it needs a host with decoded media (the native host), and `make({ open, ...options })` returns a handle with `engine`, `media`, `mediaState`, sequence operations, and joined cleanup reports. The `open` effect supplies each source and its lifetime budget. `openH3({ mint, onAllocated })` is that effect for paid H3 sessions: it mints the token, allocates the session, runs `onAllocated({ session, grant, allocation })` before connecting so the owner can be recorded durably, then connects and derives the source, with the granted length as its lifetime. The `allocation` is the record to persist (`Orchestration.Allocation`, without the token); its `endsAt` is when the granted length ends at the latest. `resumeH3({ allocation, jwt })` is the other half: after the owner died, it attaches to the recorded session with `adopt: true` and derives its source, sending only state and queue reads, never a canvas or other command a playing session refuses, with the time left until `endsAt` as its lifetime, so it is also a renewal `open`, and renewal terminates the session when it retires it. It refuses a record without `endsAt` or past it before anything is sent. `Orchestration.layer(options)` provides the handle's `Engine`, `Media` and `Handle` services from one orchestration; each build opens its own paid chain, so bind the layer to a `const`. `engine.observe(options)` is the engine's gap-free observation, as `session.observe` and `provider.observe` are for theirs: it subscribes before reading, returning the current `EngineState` with a stream of every later event (apply events idempotently by `clipId`; after an `Overflow`, observe again). `handle.observe(options)` extends it to the whole handle: the engine and media state, then engine events, renewals and media-state transitions in the one order they happened. `onRenewal` runs on its own reader and never holds the handle's command permit, and the orchestration logs through Effect's logger at debug level. Renewal measures elapsed time on Effect's monotonic clock: a source's age, its expiry, the lead, the retry cooldown and the recovery budget, as well as `BuildTiming`. A correction of the host's wall clock therefore moves no renewal and bends no build time. Recorded instants (every event's `at`, `startedAt`, `enqueuedAt` and `Allocation.endsAt`) stay epoch milliseconds of wall time. Renewal polls: each tick runs 100 ms after the previous one finished. Application scheduling, pricing, persona, and show policy stay outside the session and H3 layers.
162
162
 
163
+ `makeContinuous({ open, ...options })` is an opt-in constructor with the same Engine, media and sequence interfaces. `make`, `layer`, `Handle` and their complete `CleanupReport` keep their shape, and legacy renewal still defaults to a lifetime cap of 64 successful opens. Continuous renewal has no cumulative cap when `maxSessions` is omitted; an explicit value still caps successful opens (1..4096), and reaching it fails with `Overflow` at the next refused preparation, where legacy renewal reports a refused preparation as a failed setup and fails after three consecutive ones; a refused replacement for an expiring source fails at once. It owns at most two opening, active, recovering or retiring sources. For both constructors, close interrupts and joins every acquisition still in progress before it retires sources, and nothing is acquired once close begins or the owner's scope starts closing. Renewal, recovery and replacement stop at the same point, so an application finalizer that is slow to finish is not reported as failed renewal; commands stay admitted until close begins, so such a finalizer can still issue its last commands. Each acquisition runs on a fiber the handle owns, so an owner scope closed while the handle is still being constructed, including by a layer disposed during startup, stops the open and fails construction with a typed `Closed` refusal, or an `AcquisitionFailure` carrying its recorded lease; interrupting the construction itself stops the open before construction exits. Construction also fails with that refusal, and retires its first source, if the owner stops while that source is being activated. An open that fails only by interruption while the owner still admits sources fails as `InvalidState` ("Source acquisition was interrupted"), during construction and for a replacement. A failed first open keeps its typed failure, with any close defect beside it. Closing the handle from inside its own `open` does not complete. Bounding the owner scope's close, for example with a timeout while an application finalizer hangs, can skip the handle's own close and leave its sources open; close the handle first. A retirement or acquisition defect fails close and its owning scope with the original defect, reported once per failed attempt; cancellation by close is not a failure. Repeated close returns the same Exit, and `media.pressure` after close returns the final totals with `closed: true`. A stalled close or finalizer keeps its reservation; whole-handle close is not promised to finish within the local accounting budget. A defect or unexpected interruption in a recovery or polling worker fails `engine.failure`, observations and media readers with the original Effect Cause. While the owner remains open, state reads and subsequent commands also fail with that Cause; late recovery cannot reactivate it. Scheduler and item waiters receive it through observation without waiting for `unknownRecoveryTimeout`. Orderly scope cancellation is not a terminal failure. Explicit close still joins source cleanup, reports retirement/acquisition failures once, and leaves `mediaState` Closed; worker failure alone does not establish cleanup completion.
164
+
165
+ Continuous adapters must supply globally unique physical source IDs and never reassign a clip ID during the handle's lifetime. Source and retained clip IDs are limited to 1024 UTF-16 code units. An oversized accepted or `Started` identity is never retained: the source is replaced as having broken its contract, and a sequence member with an oversized accepted identity becomes indeterminate. Live duplicate source IDs are rejected, but historical reuse after eviction cannot be detected with bounded memory. Private incarnation tokens fence selected preparations, source-fenced enqueues and sequence owners; an entirely unbound preparation still chooses current at first submit. A selected preparation whose route moved while its source is still live refuses with `RouteChanged`; `SessionRetired` means that source retired. Completed submissions retain their original Exit independently of the old source. Retired anchors no longer retained can refuse as missing rather than `SessionRetired`; that diagnostic limit does not permit dispatch to another conforming source.
166
+
167
+ `ContinuousOptions.retainedSuccessfulCleanups` retains the newest complete details (default 64, range 0..4096). `maxUnresolvedCleanups` bounds incomplete records plus outstanding cleanup reservations (default 16, range 2..4096); capacity is reserved before allocation and exhaustion fails closed with `Overflow`. Unknown committed outcomes occupy that ledger even when canonical remote termination is confirmed. Accounting `settled` means bookkeeping completed, not that every outcome became known. Each source separately bounds accepted and distinct Started identities at 4096, with accepted capacity reserved before dispatch; repeated Started observations do not consume another entry. Sequence history keeps its independent limits and explicit acknowledgement/release.
168
+
169
+ `ContinuousHandleShape.close` returns the separate `CleanupSummary` Schema, with format `reactor-orchestration-cleanup-summary/v1` and no top-level `sessions`, so a legacy complete-history decoder rejects it. `retained` preserves canonical cleanup beside local accounting, scope and affinity evidence, including `unknownSubmissions`. Only proven complete rows may be omitted, counted separately in `omittedComplete.noAllocation`, `ownedTerminated` and `attachedDetached`; an attached detach is never counted as owned termination. `totalRetirements` equals retained rows plus omitted counts exactly; a reservation still outstanding when close concludes the summary is retained as an incomplete row, never omitted, and each row's accounting reflects its retirement's own join. Decoding rejects a row marked complete whose evidence does not prove it complete. Use `Schema.toCodecJson(CleanupSummary)` for bigint counts as decimal strings and errors as diagnostic JSON. Repeated successful close returns the same frozen summary. A defective close preserves its original Cause on every wait; `cleanup` exposes its factual summary only after retirement bookkeeping finishes and does not turn failed close into success.
170
+
163
171
  `ClipRequest.sameSessionAs` targets the physical session that owns a known clip, including one already ready or playing, while leaving queue position unchanged. `before` requests insertion ahead of a clip still in the generation queue. Source affinity, insertion anchors, continuation, and sequence ownership must agree; missing, conflicting, retired, or recovering ownership fails locally with a `not-submitted` outcome. This keeps a dependent request on its required session during renewal without inventing an insertion point.
164
172
 
165
- `Orchestration.makeScheduler(options)` is an opt-in clip scheduler over the `Engine`; `layerScheduler(options)` provides it as an Effect service. Apps submit stable keys into priority lanes, listed highest first. The `lineup(filler)` preset supplies one `line` lane above generated filler. Each lane is FIFO unless a deadline gives an earlier item priority for build admission. The scheduler admits one build at a time by default, keeps a floor and target of playable Ready seconds, and orders Ready clips within each physical session. Filler is generated by a pure `clip({ index, runwaySeconds, targetSeconds })` callback and is never owed. A replacement session has its own queue and runway during renewal; once an app clip is Ready there, the retiring session's Ready filler is withdrawn when no sequence keeps that session preferred and no old item is queued or building. The switch then follows its playing clip. It waits for that clip's missing video frames only for the renewal's `handoffGrace` past its `Ended`, or past the source first reporting nothing playing if `Ended` was lost: 250 ms by default and at most 5 seconds, since the retiring session running dry within it is not reported as `Starved`. Renewal checks every 100 ms, so the switch can come up to one check after the grace. A frame can land after `Ended`, but one the provider never sent never does. Frame loss, in that clip or earlier, and source drop totals remain on `Switched.tail`. Audio remains explicitly unverified. `EngineState.handoffReady` exposes this condition, and the `HandoffReady` engine event reports a final clip that arrived in full; neither establishes presented output. A submitted request cannot set `position`, `before`, `sameSessionAs`, `continueFrom` or sequence ownership, because those can override the scheduler's order.
173
+ `Orchestration.makeScheduler(options)` is an opt-in clip scheduler over the `Engine`; `layerScheduler(options)` provides it as an Effect service. Apps submit stable keys into priority lanes, listed highest first. The `lineup(filler)` preset supplies one `line` lane above generated filler. Each lane is FIFO unless a deadline gives an earlier item priority for build admission. The scheduler admits one build at a time by default, keeps a floor and target of playable Ready seconds, and orders Ready clips within each physical session. Filler is generated by a pure `clip({ index, runwaySeconds, targetSeconds, durationSeconds })` callback and is never owed. `durationSeconds` is a suggested requested length within `filler.lengths` (H3's 5 to 15.084 seconds by default): before an `At` anchor, one of equal clips that tile the gap the runway leaves, adjusted by the measured actual over requested length, so filler ends on the anchor instead of running past it; otherwise the shortest length, since a shorter clip brings the next boundary, and a reaction, sooner. Choosing content by that context, a category for a long gap or an anchor ahead, stays with the callback. A replacement session has its own queue and runway during renewal; once an app clip is Ready there, the retiring session's Ready filler is withdrawn when no sequence keeps that session preferred and no old item is queued or building. The switch then follows its playing clip. It waits for that clip's missing video frames only for the renewal's `handoffGrace` past its `Ended`, or past the source first reporting nothing playing if `Ended` was lost: 250 ms by default and at most 5 seconds, since the retiring session running dry within it is not reported as `Starved`. Renewal checks every 100 ms, so the switch can come up to one check after the grace. A frame can land after `Ended`, but one the provider never sent never does. Frame loss, in that clip or earlier, and source drop totals remain on `Switched.tail`. Audio remains explicitly unverified. `EngineState.handoffReady` exposes this condition, and the `HandoffReady` engine event reports a final clip that arrived in full; neither establishes presented output. A submitted request cannot set `position`, `before`, `sameSessionAs`, `continueFrom` or sequence ownership, because those can override the scheduler's order. Continuity is asked for instead: `continuity: "previous"` on an item, group part, insert or replacement builds its clip continuing from the clip that airs just before it on its session (H3 `continue_from_clip_id`, which carries motion, camera and audio across the boundary). The scheduler resolves that clip when it builds: a Ready clip or item ranked just ahead of it, else the clip playing there. It waits while that item is not built yet, and builds the clip independently when there is none or the provider no longer offers it for continuation. A clip that continues takes at most two audio references of its own. Continuity is fixed at build time, so a later insert between the two clips does not rebuild the one after it; replace that clip to continue from the insert.
174
+
175
+ Every planned `Switched` event includes immutable `handoff` evidence captured when the switch becomes eligible, before source-pressure and close waits. Its `sessionId` still names the retiring source; `handoff.replacementSessionId` names the new source. The decision is `no-observed-start`, `count-complete` or `grace-elapsed`, with the final clip's local decoded-frame counts and the observed grace origin (`Ended` or `Idle`) when available. `no-observed-start` means no local `Started` observation; it does not prove nothing played. Aggregate `tail` remains unchanged. The public `handoff` field is optional so historical event values remain assignable. These observations do not establish audio or presented-output completeness, and hosted qualification remains unrun.
176
+
177
+ The `scheduler-renewal` qualification harness uses the public orchestration owner, `openH3`, scheduler and accepted drain. Its offline matrix exercises `make` and `makeContinuous`; paid qualification selects continuous with `retainedSuccessfulCleanups: 1`, `maxUnresolvedCleanups: 2` and `maxSessions: 2`. It retains both original source-cleanup reports and reconciles the compact summary. No paid scheduler-renewal run has occurred; hosted timing, audio completeness and presented or encoded output remain unqualified.
178
+
179
+ `submit({ key, lane, request, window, start })` returns a handle with `started`, `outcome` and `firstDecisive` effects. `started` and `firstDecisive` retain the first observed start or definitive disposition; `outcome` waits for the end or definitive disposition. None settles on interim `Unknown`. Repeating a retained key and spec returns the same handle; a changed spec fails `KeyMismatch`. Active keys are retained until settled. `maxHistory` bounds completed key retention (4096 by default, zero disables history); older completed keys can be submitted anew once evicted. Handles already held by callers keep their original results. Applications needing longer deduplication retain their own key ledger. `window.notBefore` and `window.startBy` are relative monotonic durations, with firm deadlines dropped on expiry and soft deadlines recorded late at start. `start` defaults to `Follow` (the next boundary in its lane); `At` names an epoch millisecond anchor and a late policy (`nextBoundary`, `skipIfLaterThan`, or `drop`); `Asap` airs at the next boundary ahead of everything waiting in every lane and builds first; `Manual` is built ahead and held until `release(key)`, which sends it to the next boundary as `Asap`. A held item ranks behind everything, is not runway, and is built early only while filler keeps the runway at its floor; if it would still be next with less than 1.5 s of the playing clip left, it is removed and rebuilt, as a future `At` clip is. With filler off it is built once released. A drain withdraws a held item, since it cannot air without a release. `release` of a key that holds nothing fails with `InvalidRequest`. The scheduler fills toward an upcoming anchor, and cuts a playing clip only for a lane declared with `cut: true`. `WouldMissDeadline` rejects an item that cannot start before its deadline: after the rest of the playing clip and the Ready clips ranked ahead of it, and, once the scheduler has measured three builds, after its own build and every build that must go before it (the one in flight, higher lanes, a replacement or a started group in its lane, and earlier deadlines). A negative `startBy` offset is refused too. The projection is optimistic, so a refusal means the deadline cannot be met. After the same measurements, a firm item that can no longer start before its deadline, because work arrived ahead of it, is dropped as `late` before it takes the build slot. The scheduler measures each build from sending it to its clip being Ready, per requested second of clip, and the actual over the requested length; `state.estimates` reports the median and p95 of its recent builds. A nonzero runway floor is raised to one p95 build of the next filler clip plus a second, so a refill started at the floor is Ready before the picture runs out; a zero floor still keeps filler off. The runway counts the playing clip from the engine's own start observation, so a new clip is never counted as empty while its Started event is being handled. A refused `At` removal is paced and retried; an uncertain removal waits for a fresh observation before retrying. Actual starts remain observable even when the provider could not hold the anchor. `withdraw(key)` waits for a provider-confirmed removal, including an in-flight build. A refused removal is not an outcome: the scheduler retries it a second later, and again after each refusal, until the clip is removed (`withdrawn`), starts (`already-started`) or settles another way (`not-found` for a failure, `already-started` if it ended or its start went unobserved). Only an unknown removal outcome fails the call, since the removal may already have taken effect. `drain()` stops admission, withdraws waiting clips and waits for the current clip to end. `drain({ finish: "accepted" })` lets all accepted items reach their disposition, including those still waiting to build, and keeps filler playing and refilling until every one of them is Ready, with its `At` anchor reached, has started or has settled, so a build in progress does not freeze the host. An `Unknown` item does not hold filler, but it holds successful drain completion until it settles. The scheduler's unknown-recovery deadline bounds waiter settlement if uncertainty remains; that failure does not establish remote cleanup completion. Both then stop filler admission, and both call `engine.stopRenewal` immediately, even while an enqueue is pending: new replacements cannot open, an opening replacement is cancelled and joined, and already acquired sources may finish. Expiry still retires a source and surfaces failure if no existing replacement can continue. The first drain call selects its mode. The owner closes its orchestration handle after drain completes.
180
+
181
+ `submitGroup({ key, lane, parts, window })` submits a group: parts, each with its own key and request, that build in order and air back to back, such as the beats of one spoken line. It returns a handle per part. Once a group's first part is admitted, its remaining parts build before any other item in its lane, so a deadline can move a whole group ahead of others in its lane but never split one. Once a part has started, the group's remaining Ready parts stay ahead of the rest of their lane. A higher lane can still go in at a boundary between parts. The window applies to the first part, and a group takes no `start` mode. `withdraw` accepts a group key, which withdraws every unstarted part, or a part key, which withdraws that part and every part after it; a part key's reply is that part's own outcome. A part that fails or is dropped, other than by being replaced, withdraws the parts after it, recorded as `Dropped` with reason `withdrawn`. Repeating a group key with the same parts returns the same handle. A changed group, or a key already used by an item or part, fails with `KeyMismatch`. A group holds at most 64 parts.
182
+
183
+ `replace(key, { key, request })` amends a queued item or group part without leaving a gap. The new clip takes the old item's lane, group position, admission order, window and start, and builds first in its lane. An old item not yet admitted is swapped at once. Otherwise the old item stays in place until the new clip is Ready, then is withdrawn and settles as `Dropped` with reason `replaced`. If the old item starts first, the replacement is withdrawn instead. Replacing a group part never counts as breaking the group. A started or settled item, one already replaced, or one whose admission is uncertain cannot be replaced; the call fails with `InvalidRequest`. Repeating a replacement returns the same handle.
184
+
185
+ `SchedulerOptions.unknownRecoveryTimeout` defaults to 60 seconds and accepts a positive finite `Duration.Input` up to 10 minutes. It is read as caller data: an own or inherited data property is captured, while `null` or an accessor, on the option or inside its value, fails with `InvalidInput` without running. The original monotonic observation of an unknown dispatch starts the deadline when even one preferred-source reservation is uncertain, including with spare capacity and no waiting demand, or when its fate holds a drain. Duplicate submissions, later unknowns, snapshots and wall-clock changes do not extend an active episode. A usable Ready replacement or keyed proof can restore service; disappearance of the old source while replacement is unavailable cannot. A later drain blocked by older uncertainty uses its original age and can fail immediately. On expiry, an independent watchdog publishes the existing `Timeout` failure with `context.operation = "scheduler.unknownRecovery"`, settles item/control waiters through the terminal boundary and closes admission, even if the actor is waiting in `stopRenewal`. Unknown outcomes remain Unknown, and a build whose enqueue is already in flight settles as terminal `Unknown`, since the provider may still accept it. The deadline never releases uncertain capacity, replays a key, starts a new recovery policy or confirms remote cleanup; the orchestration owner still joins its actual cleanup. Canonical renewal already owns source replacement. Applications that relied on longer uncertainty waits must choose a larger finite budget or revise that service policy. The scheduler retains at most 4,096 uncertain filler identities and fails with `Overflow` before dispatching another.
186
+
187
+ `insert({ key, request, before | after, window })` places a clip immediately before or after an anchor: an item, a group part, or a group key, which means before the group's first part or after its last. Give exactly one of `before` and `after`. The clip takes the anchor's lane and start: after an `At` item it waits for the same anchor, and beside an `Asap` item it is `Asap` too. It builds in air order. Between two parts of a group it joins the group, so the group stays together, but it is an inserted part: its failure or withdrawal never breaks the group, and withdrawing its key withdraws only it. `after` may name the playing clip, which puts the insert at the next boundary. An insert that is not Ready when its place comes airs at the next boundary instead. Its window, like an item's, is relative to admission, and `WouldMissDeadline` counts only the Ready clips ahead of its place. An anchor that has settled, was replaced, is a held `Manual` item or whose admission is uncertain, or `before` a clip or group that has started, fails with `InvalidRequest`. Repeating an insert returns the same handle; a changed one fails with `KeyMismatch`.
188
+
189
+ `edit([...])` applies several edits as one change: `Submit`, `SubmitGroup`, `Insert`, `Replace` and `Withdraw`, each tagged, such as an acknowledgement inserted after the playing clip together with a beat the event made wrong withdrawn, or a whole plan replaced by withdrawing what is queued and submitting the new line. Every edit is checked before any takes effect, so a refused edit fails the whole batch and admits nothing; a key may appear once per batch. The batch is make-before-break. What it withdraws keeps its clip as cover: it airs only when nothing else in its lane is Ready, so a clip the batch adds airs ahead of it as soon as that clip is Ready, and a Ready replacement airs in its place. Once every clip the batch adds is Ready or has settled, the batch takes effect: its withdrawals and replacements are requested together. A withdrawn item that nothing was built for yet goes at once, since it covers nothing. When a batch withdraws or replaces a clip that another pending batch adds, that batch also waits for this one's clips, so its cover stays until something replaces it. A replacement that has started takes its place at once, so the item it replaces never follows it. The handle has one result per edit, `Added`, `AddedGroup` or `Withdrawal` with its outcome, and `committed`, which resolves when the batch takes effect and fails if the scheduler closes first. A withdrawal of an item that aired as cover reports `already-started`. `WouldMissDeadline` for an added clip does not count what the batch withdraws or replaces.
190
+
191
+ Each lane can declare how it treats a new submission and whether it may cut. `conflict: "queue"`, the default, queues it behind the lane's waiting items. `conflict: "replace"` supersedes the lane's items still waiting, make-before-break: they stay only as cover until the new item is Ready, then settle `Dropped` as `replaced`, as for a status line where only the latest matters. `conflict: "skip"` refuses the submission with `LaneBusy` while the lane has an item waiting or playing. Inserts and replacements place themselves and are not affected. A lane with `cut: true` does not wait for a boundary: once one of its items is Ready at the front of its session, the scheduler cuts a playing clip of a strictly lower lane, or filler, unless that clip ends within a second; it never cuts a clip of its own lane. The engine's `cut(clipId)` stops the clip only if it is still playing; with autoplay on the provider then starts the next Ready clip, and the cut clip settles `Ended` with termination `stopped`. On H3 a cut is `stop`, which flushes to black or holds a frame until the next clip starts; whether that shows is unqualified on hosted H3, so an application that treats a held frame as a pause should leave cutting off. There is no parallel policy: a session plays one clip at a time.
166
192
 
167
- `submit({ key, lane, request, window, start })` returns a handle with `started`, `outcome` and `firstDecisive` effects. `started` and `firstDecisive` retain the first observed start or definitive disposition; `outcome` waits for the end or definitive disposition. None settles on interim `Unknown`. Repeating a retained key and spec returns the same handle; a changed spec fails `KeyMismatch`. Active keys are retained until settled. `maxHistory` bounds completed key retention (4096 by default, zero disables history); older completed keys can be submitted anew once evicted. Handles already held by callers keep their original results. Applications needing longer deduplication retain their own key ledger. `window.notBefore` and `window.startBy` are relative monotonic durations, with firm deadlines dropped on expiry and soft deadlines recorded late at start. `start` defaults to `Follow` (the next boundary); `At` names an epoch millisecond anchor and a late policy (`nextBoundary`, `skipIfLaterThan`, or `drop`). The scheduler fills toward an upcoming anchor and never cuts a playing clip. `WouldMissDeadline` rejects an item whose known queued material already makes its deadline impossible, including a negative `startBy` offset. A refused `At` removal is paced and retried; an uncertain removal waits for a fresh observation before retrying. Actual starts remain observable even when the provider could not hold the anchor. `withdraw(key)` waits for a provider-confirmed removal, including an in-flight build. `drain()` stops admission, withdraws waiting clips and waits for the current clip to end. `drain({ finish: "accepted" })` lets all accepted items reach their disposition, including those still waiting to build, and keeps filler playing and refilling until every one of them is Ready, with its `At` anchor reached, has started or has settled, so a build in progress does not freeze the host. An `Unknown` item does not hold filler, but the drain completes only once it settles: with the renewal engine, when its source retires, which can be the end of the session; without a fenced source, when the scheduler closes. Bound a drain with a timeout when that wait matters. Both then stop filler admission, and both call `engine.stopRenewal` immediately, even while an enqueue is pending: new replacements cannot open, an opening replacement is cancelled and joined, and already acquired sources may finish. Expiry still retires a source and surfaces failure if no existing replacement can continue. The first drain call selects its mode. The owner closes its orchestration handle after drain completes.
193
+ An item, group part, insert or replacement can carry up to 32 `cues`, secondary events such as an overlay, a caption or a browser action tied to its clip: each has a `name` and fires at an offset from the clip's observed start (`{ from: "start", offset }`) or back from its end (`{ from: "end", offset }`, measured from the provider's actual length). `scheduler.cues` publishes each `{ key, name, at }` once, within the scheduler's 100 ms turn of its time, while the clip plays. A cue that falls after a clip ended early, when it was cut, never fires, and a clip whose start was not observed fires none. A cue is a scheduling fact, not proof that the frame it names was presented.
168
194
 
169
- `asRun` is an unbounded per-item lifecycle stream: Accepted, Building, Ready, Started, Ended, Dropped, Failed, Unobserved or Unknown. Each item also has an `outcome` wait. `Started.durationSeconds` is the provider-observed duration. `Failed.reason` distinguishes `Clip` failure, `Command` refusal and `Scheduler` termination, retaining the original typed cause where available. `scheduler.failure` exposes the original terminal failure; scope closure signals `Closed`, and pending or subsequent control calls fail with `SessionClosed`. `Started.at` and `Ended.at` are observed epoch times; elapsed airtime and deadline windows use Effect's monotonic clock. `Unobserved` means an acknowledged clip's start was not seen, including after observation overflow. `Unknown` means dispatch has no acknowledgment. A keyed clip observed later can still acquire its Ready or Started evidence. An absent queue snapshot cannot prove an unknown clip never played, so the scheduler never replays that key automatically. The renewal engine fences each enqueue to its selected physical source before dispatch; an unknown outcome becomes terminal when that source retires without keyed proof. With a custom engine that cannot fence its source, uncertainty stays open until the scheduler closes. A withdrawal of that key fails with the original uncertain outcome unless a provider clip is found and removed. The scheduler carries an item key in library-owned provider metadata and leaves the app's request metadata untouched. As-run records provider evidence; an app that needs proof of presented or encoded output must gather that separately.
195
+ `asRun` is an unbounded per-item lifecycle stream: Accepted, Building, Ready, Started, Ended, Dropped, Failed, Unobserved or Unknown. The plan outlives a session: when renewal replaces a lost session, an item whose clip was queued, building or Ready there, and so never aired, is carried to the replacement and rebuilt under the same key, recorded as `Accepted` again with `carried: { sessionId }` for the lost session. A clip that was playing when its session was lost still settles `Failed`, since part of it aired, and an item whose enqueue outcome was unknown on the lost session still settles as terminal `Unknown`. Each item also has an `outcome` wait. `Started.durationSeconds` is the provider-observed duration. `Failed.reason` distinguishes `Clip` failure, `Command` refusal and `Scheduler` termination, retaining the original typed cause where available. `scheduler.failure` exposes the original terminal failure only after retained item waits, actor-owned control replies and `state.accepting = false` are committed, so a supervisor may immediately close its owner without stranding those waits. An owner closed from a handle wait or an `asRun` subscriber also finds each item's recorded evidence settled, not replaced, and evidence recorded before a terminal claim is on `asRun` before that claim's settlement and before `scheduler.failure` publishes. Typed termination retains terminal `Unknown` and already observed `Started`/`firstDecisive` evidence, and a withdrawal of an item already recorded `Dropped` replies `withdrawn`; unexpected defects or interruption preserve the original Cause. The signal does not wait for resumed callers or establish remote cleanup completion. Scope closure signals `Closed`, and pending or subsequent control calls fail with `SessionClosed`. `Started.at` and `Ended.at` are observed epoch times; elapsed airtime and deadline windows use Effect's monotonic clock. `Unobserved` means an acknowledged clip's start was not seen, including after observation overflow. `Unknown` means dispatch has no acknowledgment. A keyed clip observed later can still acquire its Ready or Started evidence. An absent queue snapshot cannot prove an unknown clip never played, so the scheduler never replays that key automatically. A replay would be safe only with proof that the provider never accepted the enqueue: a queue read the provider answered after processing it, which needs H3 to process commands in the order it receives them. That ordering is not documented or qualified on hosted H3, so an unknown key stays unknown; a clip lost with a replaced session is rebuilt because it was seen queued or Ready there and never started. The renewal engine fences each enqueue to its selected physical source before dispatch; an unknown outcome becomes terminal when that source retires without keyed proof. A custom engine that cannot fence its source retains uncertainty until keyed evidence or scheduler failure; the unknown-recovery deadline prevents indefinite scheduler service behind it. A withdrawal of that key fails with the original uncertain outcome unless a provider clip is found and removed. The scheduler carries an item key in library-owned provider metadata and leaves the app's request metadata untouched. As-run records provider evidence; an app that needs proof of presented or encoded output must gather that separately.
170
196
 
171
197
  `Orchestration.Submission` models an inert prepared operation. Preparation may be interrupted before commit; once execution commits, callers joining or abandoning the result do not replay the dispatch. `CommandFailure.context` distinguishes `not-submitted`, `unknown`, and `replied` outcomes independently of the transport error category, and an engine command fails with `EngineError`, a `CommandFailure` or a local `PolicyFailure`.
172
198
 
@@ -0,0 +1,6 @@
1
+ import * as Arr from "effect/Array";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Queue from "effect/Queue";
4
+ export declare const take: <A, E>(self: Queue.Dequeue<A, E>) => Effect.Effect<A, E>;
5
+ export declare const takeAll: <A, E>(self: Queue.Dequeue<A, E>) => Effect.Effect<Arr.NonEmptyArray<A>, E>;
6
+ //# sourceMappingURL=queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/_internal/queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAoBtC,eAAO,MAAM,IAAI,GAAI,CAAC,EAAE,CAAC,QAAQ,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CACyB,CAAC;AAEnG,eAAO,MAAM,OAAO,GAAI,CAAC,EAAE,CAAC,QAAQ,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAS3F,CAAC"}
@@ -0,0 +1,30 @@
1
+ import * as Arr from "effect/Array";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Queue from "effect/Queue";
4
+ /**
5
+ * rc.117 can yield between an empty read and registering its taker, losing an
6
+ * offer's only wakeup. Recheck readiness in the same synchronous callback that
7
+ * registers the waiter. Remove once the pinned Effect includes
8
+ * https://github.com/Effect-TS/effect/pull/8472.
9
+ */
10
+ const awaitAvailable = (self) => Effect.callback((resume) => {
11
+ const state = self.state;
12
+ if (state._tag === "Done")
13
+ return resume(state.exit);
14
+ if (self.messages.length > 0 || (self.capacity <= 0 && state.offers.size > 0))
15
+ return resume(Effect.void);
16
+ state.takers.add(resume);
17
+ return Effect.sync(() => {
18
+ state.takers.delete(resume);
19
+ });
20
+ });
21
+ export const take = (self) => Effect.suspend(() => Queue.takeUnsafe(self) ?? Effect.andThen(awaitAvailable(self), take(self)));
22
+ export const takeAll = (self) => Effect.suspend(() => {
23
+ const state = self.state;
24
+ if (state._tag === "Done")
25
+ return state.exit;
26
+ // clear retains Effect's batch and backpressure handling without waiting;
27
+ // the terminal check above preserves Done, which clear deliberately omits.
28
+ return Effect.filterOrElse(Queue.clear(self), Arr.isArrayNonEmpty, () => Effect.andThen(awaitAvailable(self), takeAll(self)));
29
+ });
30
+ //# sourceMappingURL=queue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queue.js","sourceRoot":"","sources":["../../src/_internal/queue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,KAAK,CAAC;IAClD,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC,IAAI,CAAC;IAC7C,0EAA0E;IAC1E,2EAA2E;IAC3E,OAAO,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,eAAe,EAAE,GAAG,EAAE,CACtE,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CACpD,CAAC;AACJ,CAAC,CAAC,CAAC"}
package/dist/host.d.ts CHANGED
@@ -8,6 +8,7 @@
8
8
  * compose hosts through their packages and read media through their `media`
9
9
  * functions. Nothing here allocates or owns a session.
10
10
  */
11
+ export { take as takeQueue, takeAll as takeAllQueue } from "./_internal/queue.js";
11
12
  export { duration } from "./duration.js";
12
13
  export type { DurationPolicy } from "./duration.js";
13
14
  export { errorOf, parse, parsed, positiveLimit } from "./errors.js";
@@ -1 +1 @@
1
- {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,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,gBAAgB,CAAC;AAChG,YAAY,EACV,UAAU,EACV,eAAe,EACf,aAAa,EACb,QAAQ,EACR,eAAe,EACf,WAAW,EACX,UAAU,GACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/host.js CHANGED
@@ -8,6 +8,7 @@
8
8
  * compose hosts through their packages and read media through their `media`
9
9
  * functions. Nothing here allocates or owns a session.
10
10
  */
11
+ export { take as takeQueue, takeAll as takeAllQueue } from "./_internal/queue.js";
11
12
  export { duration } from "./duration.js";
12
13
  export { errorOf, parse, parsed, positiveLimit } from "./errors.js";
13
14
  export { finite, record } from "./json.js";
package/dist/host.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"host.js","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAWlF,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"host.js","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAWlF,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC"}
@@ -1,3 +1,4 @@
1
+ import * as Cause from "effect/Cause";
1
2
  import * as Effect from "effect/Effect";
2
3
  import type * as Scope from "effect/Scope";
3
4
  import * as Stream from "effect/Stream";
@@ -31,5 +32,7 @@ export declare class Observations<A> {
31
32
  end(): void;
32
33
  /** Source failure belongs to each reader, including a later subscription. */
33
34
  fail(error: ReactorError): void;
35
+ /** Owned worker defects must reach observers without becoming recoverable errors. */
36
+ failCause(cause: Cause.Cause<ReactorError>): void;
34
37
  }
35
38
  //# sourceMappingURL=observation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"observation.d.ts","sourceRoot":"","sources":["../src/observation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAyB,YAAY,EAAE,MAAM,aAAa,CAAC;AAYlE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,6FAA6F;AAC7F,qBAAa,YAAY,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,KAAK,EAAE,CAAC,EAAE,KAAK,SAAM,GAAG,IAAI,CAoBhC;IAED,GAAG,IAAI,IAAI,CAKV;IAED,6EAA6E;IAC7E,IAAI,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAE9B;IAED,qFAAqF;IACrF,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,IAAI,CAMhD;CACF"}
@@ -2,6 +2,7 @@ import * as Cause from "effect/Cause";
2
2
  import * as Effect from "effect/Effect";
3
3
  import * as Queue from "effect/Queue";
4
4
  import * as Stream from "effect/Stream";
5
+ import { take as takeQueue } from "./_internal/queue.js";
5
6
  import { parsed, positiveLimit, ReactorError } from "./errors.js";
6
7
  /** Slow observation never blocks protocol correlation or silently drops lifecycle events. */
7
8
  export class Observations {
@@ -34,7 +35,7 @@ export class Observations {
34
35
  const queue = yield* Queue.dropping(bounds.capacity);
35
36
  const subscriber = { queue, maxBytes: bounds.maxBytes, bufferedBytes: 0 };
36
37
  if (observations.failure !== undefined)
37
- Queue.failCauseUnsafe(queue, Cause.fail(observations.failure));
38
+ Queue.failCauseUnsafe(queue, observations.failure);
38
39
  else if (observations.closed)
39
40
  Queue.endUnsafe(queue);
40
41
  else
@@ -54,7 +55,7 @@ export class Observations {
54
55
  }), () => Effect.sync(() => {
55
56
  reading = false;
56
57
  }));
57
- return Stream.fromEffectRepeat(Effect.uninterruptibleMask((restore) => restore(Queue.take(subscriber.queue)).pipe(Effect.map((entry) => {
58
+ return Stream.fromEffectRepeat(Effect.uninterruptibleMask((restore) => restore(takeQueue(subscriber.queue)).pipe(Effect.map((entry) => {
58
59
  subscriber.bufferedBytes -= entry.bytes;
59
60
  return entry.value;
60
61
  }))));
@@ -96,12 +97,16 @@ export class Observations {
96
97
  }
97
98
  /** Source failure belongs to each reader, including a later subscription. */
98
99
  fail(error) {
100
+ this.failCause(Cause.fail(error));
101
+ }
102
+ /** Owned worker defects must reach observers without becoming recoverable errors. */
103
+ failCause(cause) {
99
104
  if (this.closed)
100
105
  return;
101
- this.failure = error;
106
+ this.failure = cause;
102
107
  this.closed = true;
103
108
  for (const subscriber of this.subscribers)
104
- Queue.failCauseUnsafe(subscriber.queue, Cause.fail(error));
109
+ Queue.failCauseUnsafe(subscriber.queue, cause);
105
110
  this.subscribers.clear();
106
111
  }
107
112
  }
@@ -1 +1 @@
1
- {"version":3,"file":"observation.js","sourceRoot":"","sources":["../src/observation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAiBlE,6FAA6F;AAC7F,MAAM,OAAO,YAAY;IAMM,cAAc;IAL1B,WAAW,GAAG,IAAI,GAAG,EAAiB,CAAC;IAChD,MAAM,GAAG,KAAK,CAAC;IACf,OAAO,CAA2B;IAC1C,aAAa,GAAG,EAAE,CAAC;IAEnB,YAA6B,cAAc,GAAG,EAAE;8BAAnB,cAAc;QACzC,aAAa,CAAC,cAAc,EAAE,gBAAgB,EAAE,IAAI,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IAC/B,CAAC;IAED,gGAAgG;IAChG,SAAS,CACP,OAAO,GAAuB,EAAE;QAEhC,MAAM,YAAY,GAAG,IAAI,CAAC;QAC1B,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;YACzB,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;gBAClC,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,EAAE,sBAAsB,EAAE,IAAI,CAAC;gBAC7E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B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,WAAW;YAAE,KAAK,CAAC,eAAe,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC1F,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;CACF"}
@@ -1,15 +1,15 @@
1
1
  export { ClipId, ClipRequest, ClipSequence, ClipMetadata, ReferenceImage, ReferenceAudio, Canvas, PolicyFailure, } from "./request.js";
2
2
  export { Missing, PolicyReason, Refusal, RefusalCode, SequenceRefusal } from "../errors.js";
3
- export { Engine, Media, Handle, EngineEvent, BuildTiming, PolicyCleanup, SourceCleanup, CleanupReport, } from "./types.js";
4
- export type { ClipRecord, LocalClipRecord, Playback, EngineState, EngineShape, MediaShape, MediaState, MediaSource, Source, HandleShape, HandleEvent, HandleObservation, EngineObservation, ObserveEngine, RoutedRequest, EnqueueHooks, EngineError, RemoveOutcome, } from "./types.js";
3
+ export { Engine, Media, Handle, EngineEvent, BuildTiming, PolicyCleanup, SourceCleanup, CleanupReport, CleanupSummary, } from "./types.js";
4
+ export type { ClipRecord, LocalClipRecord, Playback, EngineState, EngineShape, MediaShape, MediaState, MediaSource, Source, HandleShape, ContinuousHandleShape, HandleEvent, HandleObservation, EngineObservation, ObserveEngine, RoutedRequest, EnqueueHooks, EngineError, RemoveOutcome, } from "./types.js";
5
5
  export { emptyState, isIdle, isLive, committedMs, securedMs, pendingCount } from "./queries.js";
6
6
  export { fromH3Session, isLocalClip } from "./h3-source.js";
7
7
  export type { H3Source, SessionSourceOptions } from "./h3-source.js";
8
- export { layer, make } from "./renewal.js";
9
- export type { Options, Opened, Renewal, MediaTail } from "./renewal.js";
8
+ export { layer, make, makeContinuous } from "./renewal.js";
9
+ export type { Options, ContinuousOptions, Opened, Renewal, MediaTail } from "./renewal.js";
10
10
  export { Allocation, openH3, resumeH3 } from "./open-h3.js";
11
- export { Scheduler, makeScheduler, layerScheduler, lineup, ItemKey, KeyMismatch, WouldMissDeadline, } from "./scheduler.js";
12
- export type { ItemSpec, StartMode, FillContext, LaneSpec, SchedulerOptions, SchedulerShape, SchedulerState, AsRunStatus, FirstDecisiveStatus, AsRunEvent, ItemHandle, WithdrawOutcome, DrainOptions, ItemFailureReason, } from "./scheduler.js";
11
+ export { Scheduler, makeScheduler, layerScheduler, lineup, ItemKey, KeyMismatch, WouldMissDeadline, LaneBusy, } from "./scheduler.js";
12
+ export type { ItemSpec, GroupPart, GroupSpec, GroupHandle, ReplacementSpec, InsertSpec, Cue, CueEvent, Edit, EditResult, EditHandle, StartMode, FillContext, LaneSpec, SchedulerOptions, SchedulerShape, SchedulerState, AsRunStatus, FirstDecisiveStatus, AsRunEvent, ItemHandle, WithdrawOutcome, DrainOptions, ItemFailureReason, } from "./scheduler.js";
13
13
  export type { Allocated, OpenedH3, OpenH3Options, ResumeH3Options } from "./open-h3.js";
14
14
  export * as References from "./references.js";
15
15
  export * as Sequences from "../Sequence.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/orchestration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,cAAc,EACd,MAAM,EACN,aAAa,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC5F,OAAO,EACL,MAAM,EACN,KAAK,EACL,MAAM,EACN,WAAW,EACX,WAAW,EACX,aAAa,EACb,aAAa,EACb,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,UAAU,EACV,eAAe,EACf,QAAQ,EACR,WAAW,EACX,WAAW,EACX,UAAU,EACV,UAAU,EACV,WAAW,EACX,MAAM,EACN,WAAW,EACX,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W,EACX,eAAe,EACf,UAAU,EACV,GAAG,EACH,QAAQ,EACR,IAAI,EACJ,UAAU,EACV,UAAU,EACV,SAAS,EACT,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,WAAW,EACX,mBAAmB,EACnB,UAAU,EACV,UAAU,EACV,eAAe,EACf,YAAY,EACZ,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC"}
@@ -1,11 +1,11 @@
1
1
  export { ClipId, ClipRequest, ClipSequence, ClipMetadata, ReferenceImage, ReferenceAudio, Canvas, PolicyFailure, } from "./request.js";
2
2
  export { Missing, PolicyReason, Refusal, RefusalCode, SequenceRefusal } from "../errors.js";
3
- export { Engine, Media, Handle, EngineEvent, BuildTiming, PolicyCleanup, SourceCleanup, CleanupReport, } from "./types.js";
3
+ export { Engine, Media, Handle, EngineEvent, BuildTiming, PolicyCleanup, SourceCleanup, CleanupReport, CleanupSummary, } from "./types.js";
4
4
  export { emptyState, isIdle, isLive, committedMs, securedMs, pendingCount } from "./queries.js";
5
5
  export { fromH3Session, isLocalClip } from "./h3-source.js";
6
- export { layer, make } from "./renewal.js";
6
+ export { layer, make, makeContinuous } from "./renewal.js";
7
7
  export { Allocation, openH3, resumeH3 } from "./open-h3.js";
8
- export { Scheduler, makeScheduler, layerScheduler, lineup, ItemKey, KeyMismatch, WouldMissDeadline, } from "./scheduler.js";
8
+ export { Scheduler, makeScheduler, layerScheduler, lineup, ItemKey, KeyMismatch, WouldMissDeadline, LaneBusy, } from "./scheduler.js";
9
9
  export * as References from "./references.js";
10
10
  export * as Sequences from "../Sequence.js";
11
11
  export * as Submission from "../Submission.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/orchestration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,cAAc,EACd,MAAM,EACN,aAAa,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC5F,OAAO,EACL,MAAM,EACN,KAAK,EACL,MAAM,EACN,WAAW,EACX,WAAW,EACX,aAAa,EACb,aAAa,EACb,aAAa,GACd,MAAM,YAAY,CAAC;AAqBpB,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAChG,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE5D,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EACL,SAAS,EACT,aAAa,EACb,cAAc,EACd,MAAM,EACN,OAAO,EACP,WAAW,EACX,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AAkBxB,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/orchestration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,cAAc,EACd,MAAM,EACN,aAAa,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC5F,OAAO,EACL,MAAM,EACN,KAAK,EACL,MAAM,EACN,WAAW,EACX,WAAW,EACX,aAAa,EACb,aAAa,EACb,aAAa,EACb,cAAc,GACf,MAAM,YAAY,CAAC;AAsBpB,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAChG,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE5D,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EACL,SAAS,EACT,aAAa,EACb,cAAc,EACd,MAAM,EACN,OAAO,EACP,WAAW,EACX,iBAAiB,EACjB,QAAQ,GACT,MAAM,gBAAgB,CAAC;AA4BxB,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC"}
@@ -1,3 +1,4 @@
1
+ import * as Cause from "effect/Cause";
1
2
  import * as Effect from "effect/Effect";
2
3
  import * as Stream from "effect/Stream";
3
4
  import { ReactorError } from "../errors.js";
@@ -25,7 +26,7 @@ export declare const make: (limits?: Limits) => Effect.Effect<{
25
26
  queuedVideoFrames: number;
26
27
  queuedAudioSamples: number;
27
28
  };
28
- fail: (cause: ReactorFailure) => void;
29
+ failCause: (cause: Cause.Cause<ReactorFailure>) => void;
29
30
  end: () => void;
30
31
  }, never, never>;
31
32
  //# sourceMappingURL=media-buffer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"media-buffer.d.ts","sourceRoot":"","sources":["../../src/orchestration/media-buffer.ts"],"names":[],"mappings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AAgE;AAChE,eAAO,MAAM,aAAa,EAAE,MAAsD,CAAC;AAEnF,wGAAwG;AACxG,eAAO,MAAM,IAAI,YAAY,MAAM;wBAUJ,UAAU,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC;wBAc9C,UAAU,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC;;;;;;;;;;;;uBA+BpD,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,KAAG,IAAI;eAM5C,IAAI;gBAOf,CAAC"}
@@ -2,6 +2,7 @@ import * as Cause from "effect/Cause";
2
2
  import * as Effect from "effect/Effect";
3
3
  import * as Queue from "effect/Queue";
4
4
  import * as Stream from "effect/Stream";
5
+ import { take as takeQueue } from "../_internal/queue.js";
5
6
  import { ReactorError } from "../errors.js";
6
7
  /**
7
8
  * One reader at a time drains a queue. A second concurrent reader fails with
@@ -18,7 +19,7 @@ const singleReader = (kind, queue, taken) => {
18
19
  return Effect.void;
19
20
  }), () => Effect.sync(() => {
20
21
  reading = false;
21
- })).pipe(Effect.as(Stream.fromEffectRepeat(Effect.uninterruptibleMask((restore) => restore(Queue.take(queue)).pipe(Effect.map((value) => {
22
+ })).pipe(Effect.as(Stream.fromEffectRepeat(Effect.uninterruptibleMask((restore) => restore(takeQueue(queue)).pipe(Effect.map((value) => {
22
23
  taken(value);
23
24
  return value;
24
25
  })))))));
@@ -74,12 +75,12 @@ export const make = (limits = defaultLimits) => Effect.gen(function* () {
74
75
  queuedBytes: queuedVideoBytes + queuedSamples * 2,
75
76
  }),
76
77
  forwarded: () => ({ queuedVideoFrames: queuedFrames, queuedAudioSamples: queuedSamples }),
77
- fail: (cause) => {
78
+ failCause: (cause) => {
78
79
  if (ended)
79
80
  return;
80
81
  ended = true;
81
- Queue.failCauseUnsafe(video, Cause.fail(cause));
82
- Queue.failCauseUnsafe(audio, Cause.fail(cause));
82
+ Queue.failCauseUnsafe(video, cause);
83
+ Queue.failCauseUnsafe(audio, cause);
83
84
  },
84
85
  end: () => {
85
86
  if (ended)
@@ -1 +1 @@
1
- {"version":3,"file":"media-buffer.js","sourceRoot":"","sources":["../../src/orchestration/media-buffer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAI5C;;;;;GAKG;AACH,MAAM,YAAY,GAAG,CACnB,IAAY,EACZ,KAAqC,EACrC,KAAyB,EACW,EAAE;IACtC,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,OAAO,MAAM,CAAC,MAAM,CAClB,MAAM,CAAC,cAAc,CACnB,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE;QAClB,IAAI,OAAO;YACT,OAAO,MAAM,CAAC,IAAI,CAChB,YAAY,CAAC,QAAQ,CACnB,gBAAgB,EAChB,iBAAiB,IAAI,+BAA+B,EACpD,EAAE,OAAO,EAAE,eAAe,EAAE,CAC7B,CACF,CAAC;QACJ,OAAO,GAAG,IAAI,CAAC;QACf,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC,CAAC,EACF,GAAG,EAAE,CACH,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;QACf,OAAO,GAAG,KAAK,CAAC;IAClB,CAAC,CAAC,CACL,CAAC,IAAI,CACJ,MAAM,CAAC,EAAE,CACP,MAAM,CAAC,gBAAgB,CACrB,MAAM,CAAC,mBAAmB,CAAC,CAAC,OAAO,EAAE,EAAE,CACrC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAC7B,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACnB,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,OAAO,KAAK,CA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IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC;QACxE,CAAC,CAAC;QACF,KAAK,EAAE,YAAY,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;YAC5C,aAAa,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;YACtC,iBAAiB,EAAE,CAAC;QACtB,CAAC,CAAC;QACF,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC;YACf,WAAW,EAAE,YAAY;YACzB,WAAW,EAAE,iBAAiB;YAC9B,WAAW,EAAE,gBAAgB,GAAG,aAAa,GAAG,CAAC;SAClD,CAAC;QACF,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,iBAAiB,EAAE,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,CAAC;QACzF,SAAS,EAAE,CAAC,KAAkC,EAAQ,EAAE;YACtD,IAAI,KAAK;gBAAE,OAAO;YAClB,KAAK,GAAG,IAAI,CAAC;YACb,KAAK,CAAC,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YACpC,KAAK,CAAC,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACtC,CAAC;QACD,GAAG,EAAE,GAAS,EAAE;YACd,IAAI,KAAK;gBAAE,OAAO;YAClB,KAAK,GAAG,IAAI,CAAC;YACb,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YACvB,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;KACF,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -1,3 +1,5 @@
1
+ import type { ClipId } from "./request.js";
2
+ import type { Renewal } from "./types.js";
1
3
  /** Pure renewal policy. Inputs are observations, never resource handles or effects. */
2
4
  export type RecoveryMode = "reconnect" | "replace";
3
5
  export type SourcePhase = {
@@ -49,8 +51,12 @@ export declare const decideRenewal: (facts: RenewalFacts) => RenewalDecision;
49
51
  /** The retiring source's last started clip, as its owner has observed it. */
50
52
  export interface FinalClip {
51
53
  readonly video: "not-started" | "count-complete" | "incomplete";
52
- /** Monotonic milliseconds since that clip's Ended was observed; undefined while it plays. */
54
+ readonly clipId: ClipId | undefined;
55
+ readonly expectedVideoFrames: number;
56
+ readonly receivedVideoFrames: number;
57
+ /** Monotonic milliseconds since Ended or the idle fallback; undefined while it plays. */
53
58
  readonly endedAgoMs: number | undefined;
59
+ readonly graceOrigin: "Ended" | "Idle" | undefined;
54
60
  }
55
61
  export interface HandoffFacts {
56
62
  readonly sequenceOpen: boolean;
@@ -66,7 +72,13 @@ export interface HandoffFacts {
66
72
  * instead left the retiring source idle until expiry. The shortfall is still
67
73
  * reported, with any earlier loss, on the retirement's tail.
68
74
  */
69
- export declare const finalClipSettled: (clip: FinalClip, graceMs: number) => boolean;
75
+ export declare const finalClipSettled: (clip: Pick<FinalClip, "video" | "endedAgoMs">, graceMs: number) => boolean;
76
+ type Handoff = NonNullable<Extract<Renewal, {
77
+ readonly _tag: "Switched";
78
+ }>["handoff"]>;
79
+ /** One decision owns both admission and evidence, so the two cannot disagree at a grace boundary. */
80
+ export declare const handoffEvidence: (facts: HandoffFacts) => Omit<Handoff, "replacementSessionId"> | undefined;
70
81
  export declare const canHandoff: (facts: HandoffFacts) => boolean;
71
82
  export declare const needsReplacement: (phase: SourcePhase, indeterminate: boolean, isExpired: boolean) => boolean;
83
+ export {};
72
84
  //# sourceMappingURL=renewal-state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"renewal-state.d.ts","sourceRoot":"","sources":["../../src/orchestration/renewal-state.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,SAAS,CAAC;AAEnD,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GAC3B;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC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AK,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;AAEvF,qGAAqG;AACrG,eAAO,MAAM,eAAe,UACnB,YAAY,KAClB,IAAI,CAAC,OAAO,EAAE,sBAAsB,CAAC,GAAG,SAoC1C,CAAC;AAEF,eAAO,MAAM,UAAU,UAAW,YAAY,KAAG,OAA+C,CAAC;AAEjG,eAAO,MAAM,gBAAgB,UACpB,WAAW,iBACH,OAAO,aACX,OAAO,KACjB,OACsF,CAAC"}
@@ -57,9 +57,39 @@ export const decideRenewal = (facts) => {
57
57
  * reported, with any earlier loss, on the retirement's tail.
58
58
  */
59
59
  export const finalClipSettled = (clip, graceMs) => clip.video !== "incomplete" || (clip.endedAgoMs !== undefined && clip.endedAgoMs >= graceMs);
60
- export const canHandoff = (facts) => !facts.sequenceOpen &&
61
- facts.currentIdle &&
62
- facts.replacementReady &&
63
- finalClipSettled(facts.finalClip, facts.graceMs);
60
+ /** One decision owns both admission and evidence, so the two cannot disagree at a grace boundary. */
61
+ export const handoffEvidence = (facts) => {
62
+ if (facts.sequenceOpen ||
63
+ !facts.currentIdle ||
64
+ !facts.replacementReady ||
65
+ !finalClipSettled(facts.finalClip, facts.graceMs))
66
+ return undefined;
67
+ const clip = facts.finalClip;
68
+ return Object.freeze({
69
+ decision: clip.clipId === undefined
70
+ ? "no-observed-start"
71
+ : clip.video === "incomplete"
72
+ ? "grace-elapsed"
73
+ : "count-complete",
74
+ finalClip: clip.clipId === undefined
75
+ ? Object.freeze({ _tag: "NoObservedStart" })
76
+ : Object.freeze({
77
+ _tag: "Observed",
78
+ clipId: clip.clipId,
79
+ expectedVideoFrames: clip.expectedVideoFrames,
80
+ receivedVideoFrames: clip.receivedVideoFrames,
81
+ videoStatus: clip.video === "incomplete" ? "incomplete" : "count-complete",
82
+ }),
83
+ grace: clip.endedAgoMs === undefined || clip.graceOrigin === undefined
84
+ ? Object.freeze({ _tag: "NotObserved" })
85
+ : Object.freeze({
86
+ _tag: "Observed",
87
+ origin: clip.graceOrigin,
88
+ elapsedMs: clip.endedAgoMs,
89
+ limitMs: facts.graceMs,
90
+ }),
91
+ });
92
+ };
93
+ export const canHandoff = (facts) => handoffEvidence(facts) !== undefined;
64
94
  export const needsReplacement = (phase, indeterminate, isExpired) => indeterminate || isExpired || (phase._tag === "Recovering" && phase.mode === "replace");
65
95
  //# sourceMappingURL=renewal-state.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"renewal-state.js","sourceRoot":"","sources":["../../src/orchestration/renewal-state.ts"],"names":[],"mappings":"AAeA,kGAAkG;AAClG,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAkB,EAAE,KAAuB,EAAe,EAAE;IAC3F,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,QAAQ;YACX,OAAO,KAAK,CAAC;QACf,KAAK,SAAS;YACZ,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QAC9D,KAAK,QAAQ;YACX,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;gBACnB,KAAK,SAAS;oBACZ,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;gBAClD,KAAK,OAAO;oBACV,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;gBAC7B;oBACE,OAAO,KAAK,CAAC;YACjB,CAAC;QACH,KAAK,YAAY;YACf,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;gBACnB,KAAK,SAAS;oBACZ,OAAO,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,KAAK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AAI,CAAC,KAAK,KAAK,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,gBAAgB;aAC3E,CAAC;QACR,KAAK,EACH,IAAI,CAAC,UAAU,KAAK,SAAS,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS;YAC7D,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;YACxC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;gBACZ,IAAI,EAAE,UAAU;gBAChB,MAAM,EAAE,IAAI,CAAC,WAAW;gBACxB,SAAS,EAAE,IAAI,CAAC,UAAU;gBAC1B,OAAO,EAAE,KAAK,CAAC,OAAO;aACvB,CAAC;KACT,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAmB,EAAW,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC;AAEjG,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,KAAkB,EAClB,aAAsB,EACtB,SAAkB,EACT,EAAE,CACX,aAAa,IAAI,SAAS,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,YAAY,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC"}
@@ -4,7 +4,7 @@ import * as Effect from "effect/Effect";
4
4
  import * as Layer from "effect/Layer";
5
5
  import * as Scope from "effect/Scope";
6
6
  import { AcquisitionFailure, ReactorError } from "../errors.js";
7
- import type { HandleShape, Renewal, Source } from "./types.js";
7
+ import type { ContinuousHandleShape, HandleShape, Renewal, Source } from "./types.js";
8
8
  import type { Engine, Handle, Media } from "./types.js";
9
9
  export type { MediaTail, Renewal } from "./types.js";
10
10
  /** An opened source and how long its remote session may live. */
@@ -66,10 +66,34 @@ export interface Options<R = never> {
66
66
  readonly onRenewal?: (event: Renewal) => Effect.Effect<void>;
67
67
  }
68
68
  /**
69
- * Explicit application policy for renewal, sequence affinity and continuous
70
- * recovering media. A physical source still owns each connection generation.
69
+ * Each open must supply a globally unique physical source ID; clip IDs must
70
+ * never be reassigned during this handle's lifetime. Continuous mode checks live
71
+ * collisions, but cannot detect historical reuse after eviction with bounded memory.
72
+ * Source/clip IDs are limited to 1024 UTF-16 code units; each source admits at most
73
+ * 4096 accepted IDs and 4096 distinct Started IDs. Sequence history still requires
74
+ * explicit acknowledgement/release and keeps its independent bounds.
71
75
  */
76
+ export interface ContinuousOptions<R = never> extends Options<R> {
77
+ /** Supply globally unique source IDs and never reassign clip IDs; historical reuse cannot be checked after eviction. */
78
+ readonly open: Options<R>["open"];
79
+ /** No cumulative successful-open cap when omitted; explicit values retain legacy semantics. */
80
+ readonly maxSessions?: number;
81
+ /** Newest complete cleanup details retained, 0..4096; defaults to 64. */
82
+ readonly retainedSuccessfulCleanups?: number;
83
+ /**
84
+ * Incomplete cleanup or unknown-submission records plus outstanding reservations,
85
+ * 2..4096; defaults to 16. Unknown outcomes can exhaust it despite confirmed termination.
86
+ */
87
+ readonly maxUnresolvedCleanups?: number;
88
+ }
89
+ /** Legacy renewal retains complete cleanup history and defaults to 64 successful opens. */
72
90
  export declare const make: <R>(options: Options<R>) => Effect.Effect<HandleShape, ReactorError | AcquisitionFailure, Scope.Scope | Crypto.Crypto | R>;
91
+ /**
92
+ * Bounded continuous renewal. Adapters must meet ContinuousOptions' unique-ID
93
+ * precondition. Retired anchors no longer retained can refuse as missing rather
94
+ * than SessionRetired; captured operations remain fenced to their exact incarnation.
95
+ */
96
+ export declare const makeContinuous: <R>(options: ContinuousOptions<R>) => Effect.Effect<ContinuousHandleShape, ReactorError | AcquisitionFailure, Scope.Scope | Crypto.Crypto | R>;
73
97
  /**
74
98
  * The handle's `Engine`, `Media` and `Handle` services from one orchestration,
75
99
  * so the three can never come from two paid session chains. Each build of the