RFC: Worker Lifecycle - #632
Conversation
| The [Product Manifest Format](product-manifest.md) defines the worker as the product's single background process and | ||
| does not say when it runs. A worker that runs for the life of the host is a signing-capable process per product running | ||
| unobserved. A worker that runs only with the product's app view cannot serve a chat room while the view is closed. Every | ||
| modality that calls a worker needs the same rule. |
There was a problem hiding this comment.
the same rule
You mean follow the requirements below ?
| 1. **Single.** A product has one worker process, however many modalities call it. | ||
| 2. **Demand-driven.** The worker runs only while the host has work that only the worker can do. | ||
| 3. **Stoppable.** The host may stop an unreferenced worker at any time and the product keeps working. | ||
| 4. **Setup.** An acknowledged product gets a run before anything calls its worker. |
There was a problem hiding this comment.
what is an acknowledged product
| 2. **Demand-driven.** The worker runs only while the host has work that only the worker can do. | ||
| 3. **Stoppable.** The host may stop an unreferenced worker at any time and the product keeps working. | ||
| 4. **Setup.** An acknowledged product gets a run before anything calls its worker. | ||
| 5. **Additive.** No wire change; the host starts and stops the worker executable. |
There was a problem hiding this comment.
No wire change
not sure what this refer to
|
|
||
| ### References | ||
|
|
||
| A reference is held for exactly as long as its work is on screen or in flight. Several references of one product hold |
There was a problem hiding this comment.
A reference is held for exactly as long as its work is on screen or in flight. Several references of one product
Can you give an example where we have several references of one product?
I guess this can happen with input modalities & pocket for example both referencing the same product?
| When the host acknowledges a product, it takes a time-limited reference on the worker. Acknowledgement may be a pin, an | ||
| addition to widgets or pocket, or the adoption of a new deployment of an acknowledged product. Nothing calls the worker | ||
| during the grant. The window is host policy, and the host releases the reference whether or not the worker is done, so | ||
| setup is idempotent and resumes on the next start. |
There was a problem hiding this comment.
having a concrete use case as an example would help here.
|
|
||
| ### Product rules | ||
|
|
||
| - A worker tolerates being stopped whenever nothing references it, including mid-setup and while its output is on |
There was a problem hiding this comment.
I guess the worker does not have to tolerate anything, it's more that the host will kill / unload it when it's refcount drops to 0
| - A worker tolerates being stopped whenever nothing references it, including mid-setup and while its output is on | ||
| screen. State that must survive goes through host storage. | ||
| - A worker does not read being started as user intent. | ||
| - A worker does no background work of its own. Proactive wakeups are the host's to schedule and are a separate RFC. |
There was a problem hiding this comment.
it does not and it can't
|
Issue: #663 |
be6c820 to
f6f6565
Compare
RFC:
docs/rfcs/worker-lifecycle.md.Second of a four-PR stack: Subscription Typed Interrupt Payload (#631) → Worker Lifecycle (#632) → Unified Renderer (#633) → Input Modality (#634). Based on the typed-interrupt branch.
Why this RFC exists
The Product Manifest Format defines the worker as the product's single background process and does not say when it runs. A worker that runs for the life of the host is a signing-capable process per product running unobserved. A worker that runs only with the app view cannot serve a chat room while the view is closed. Every modality that calls a worker needs one rule, and the Unified Renderer and Input Modality RFCs both name what holds a worker in terms defined here.
What it defines
Implementation
Part of this PR. The reference-counted worker manager lives in
truapi-serverand hosts implement the start/stop hook; no worker executable is started by this repo today, so the manager and the platform hook are both new.truapi-platform: worker start/stop hooktruapi-server: per-product reference count, acknowledgement grant, chat holders onChatConnectiontest_support.rsand runtime tests