The QoL ("quality of life") context is a stream-governance layer over the Transcode context. It predicts per-stream CPU cost from observed utilization, enforces a global CPU budget across concurrent transcodes, downgrades quality tiers (or rejects streams) when the budget is exhausted, filters manifests to the allowed tiers, and monitors streams mid-flight for emergency release. QoL is service-based: it has no aggregate roots — its state is an in-memory StreamGovernor whose learning data is persisted to JSON files by infrastructure subscribers.
Core domain service: budget evaluation, tier downgrade/rejection, active-stream tracking, profile management, learning-model coordination, and state export/import
LearningModel
Linear-regression model (4-feature OLS via Gaussian elimination) predicting per-stream CPU% from source height, target bitrate, and hardware-acceleration flag; trains at 50 samples, falls back to per-tier averaging
Transcode Infrastructure implements the quality-ladder and encoder-profile contracts and calls the stream-admission and allowed-tier contracts. QoL references no Transcode class.
Backs QoLAdminPortInterface, delegates to the StreamGovernor singleton
StreamAdmissionService
Port implementation
Backs StreamAdmissionPortInterface: evaluates the budget and allocates the stream (throws StreamBudgetExhausted to veto), records completion samples and releases streams
AllowedQualityTiersService
Port implementation
Backs AllowedQualityTiersPortInterface from the governor's allowed tiers
LearningDataPersister
Persister
Persists governor learning state to JSON files (dual-throttled writes)
CpuGpuSampler
Swoole bootable
Samples CPU/GPU utilization every second into a Swoole\Table (no pooled services in timer)
MidStreamMonitor
Swoole timer
Polls utilization every 5s; triggers emergency stream release on sustained over-budget
BudgetGuard
Port implementation
Mid-stream capacity check against sampled CPU (implements BudgetGuardInterface)
See the Architecture page for details on cross-context event flow, and the Anti-Corruption Layer page for the streaming-decorator chain.