--- status: draft date: 2026-03-11 --- # SPF — Streaming Playback Framework > **This is a living design document for a highly tentative codebase.** The current implementation captures useful early lessons but is expected to undergo significant architectural change in the near term. [architecture.md](architecture.md) and [decisions.md](decisions.md) document the current state; [primitives.md](primitives.md) is the forward-looking design. > > **Structure note:** These docs don't follow the standard [design doc template](../README.md) (`Decision → Context → Alternatives → Rationale`). SPF's scope — a multi-layered streaming framework with several interacting primitives — warrants a different structure: an index with glossary, per-primitive deep dives, and explicit "Open questions" sections for areas still in flux. A lean, actor-based framework for HLS playback over MSE. Handles manifest parsing, quality selection, segment buffering, and end-of-stream coordination — without a monolithic player. Actors and Reactors are defined via declarative factory functions (`createMachineActor`, `createMachineReactor`) backed by TC39 Signals. ## Contents | Document | Purpose | | ---------------------------------------------------------- | ------------------------------------------------------------- | | [index.md](index.md) | Overview, problem, quick start, surface API | | [primitives.md](primitives.md) | Foundational building blocks (Tasks, Actors, Reactors, State) | | [signals.md](signals.md) | Signals as the reactive primitive — decision, tradeoffs, friction | | [actor-reactor-factories.md](actor-reactor-factories.md) | Decided design for `createMachineActor` / `createMachineReactor` factories | | [text-track-architecture.md](text-track-architecture.md) | Reference Actor/Reactor implementation + spike assessment | | [architecture.md](architecture.md) | Current implementation: layers, components, data flow | | [decisions.md](decisions.md) | Decided and open design decisions | ## Glossary | Term | Definition | | ---- | ---------- | | **Actor** | Long-lived stateful worker that processes messages serially via a queue. Owns a context snapshot and a Runner. Key examples: `SourceBufferActor`, `SegmentLoaderActor`. | | **Reactor** | Thin subscriber that observes state changes and translates them into actor messages. Contains no business logic beyond "should I send a message, and what should it say?" | | **Task** | Ephemeral async work unit with status tracking (`pending`, `active`, `complete`, `error`) and abort support. | | **Runner** | Task scheduler that controls execution ordering. `SerialRunner` runs one task at a time; `ConcurrentRunner` runs tasks in parallel. | | **Snapshot** | Reactive read-only state of an Actor or Reactor, exposed for external consumption. | | **Signal** | Reactive primitive from the [TC39 Signals proposal](https://github.com/tc39/proposal-signals). The layer underneath Actors and Reactors — see [signals.md](signals.md). | | **MSE** | [Media Source Extensions](https://developer.mozilla.org/en-US/docs/Web/API/Media_Source_Extensions_API) — browser API for programmatically feeding media data to a `