Typed structured-worker contract for host.workers API 1.
Import service to select an implementation before requiring nupp.workers. A provider owns its lane scheduler, but uses the canonical Scope, PublicScope, ScopeToken, Task, and submitted-signature types declared here. Generic spawn must preserve the exact argument and result packs of the sendable function.
Arguments and results cross isolated Lua states as copies. Only explicitly supported engine-backed affine owners move; arbitrary closures, pointers, coroutines, and Lua-owned affine resources cannot be copied as task arguments. Runtime validation must also reject unsupported value graphs that static types cannot exclude. A task's result count preserves embedded and trailing nil values. await returns that exact pack or raises failure/cancellation; isDone reports terminal settlement, status reports scheduler state, and cancel reports whether it made the first cancellation request.
Scope cleanup settles all children, including those never awaited, before propagating unobserved failure. Cancellation uses nupp.runtime.services.cancellation. Blocking waits cooperate with the selected suspension implementation and must not acquire a new service during settlement.
Before loading child consumers, initialize each lane from the artifact catalog, replay catalog-backed named selections, and require setup modules registered with nupp.services.setupWorkers. Capture that configuration before workers become active. Instances and Lua closures are never transferred; runtime-only registrations require explicit setup in the destination state.
Complete worker implementation protocol, including structured-task integration. Implement generic spawn and ownership guarantees through the shared scope types.
Waits for a task and returns status, packed values, exact count, and problem. Status is done, failed, or cancelled; cancellation preserves its shared identity.
Closes the scope on every structured exit. A settling terminal: under a suspension handler it parks until every child has settled, and without one it blocks.
What may actually be submitted: a module member, or an outlined literal whose effectively-final captures can be copied to another lane. Exported so a task scope can hold its fork to the same bound without linking this module.
The arguments a submitted function takes, once its whole signature is known to be copyable. Reached only from spawn: naming Task<F> describes a handle rather than a crossing, so a signature is held to this where it is submitted and nowhere else.