Rulvar API reference / @rulvar/cli / createWorker
Function: createWorker()
ts
function createWorker(engine, options): Worker;Defined in: packages/cli/src/worker.ts:358
The queue shell over the public engine API (M8, FR-703): leases resumable and suspended runs from a LeasableStore under the fencing epoch and drives each through engine.resume.
It is not a regulated worker. What it does NOT check (plan 49 wave B, the RV4913 remainder; the same list as CreateWorkerOptions):
- It asserts no resume posture of its own:
engine.resumereceives{ ...resumeOptions, args, lease }, and without a host suppliedresumeOptionsthe engine defaults decide (bodyHash'warn', a recordedconfigFingerprintunchecked, a recordedscoperestored without an assertion, open wire intents refused and poisoned). The worker computes none of those values; the function form sees the run'sRunMetaso the host re asserts what genesis recorded or throws aConfigErrorto refuse. - It compiles no regulated profile and attests nothing; the only bridge is
resumeOptions.configFingerprint, which the ENGINE compares against the genesis record before ownership. - It trusts
argsFor: arguments are not journaled, the engine recordsargsProvidedandargsHashat genesis and does not enforce them, and the worker compares nothing; the refusal is the host's (hashRunArgs(args)againstmeta.argsHash), which is whatrulvar resumedoes and--allow-args-changeoverrides. - It bounds no money and no admission:
concurrencycaps leased runs in one process only; a run's ceiling is its recorded one (or the host'sresumeOptions.runoverride, journaled by the engine), and no fleet wide cap on active runs lives here. - It selects nothing by identity: every
runningorsuspendedmeta in the store is a candidate whatever its tenant, region, or account; separate stores, or refuse per run from theresumeOptionsfunction. - It reads the meta row, never the journal, for candidacy; the divergences
rulvar runs auditnames are invisible to a sweep. - Poison is process local and retry is unbounded: a poisoned run is skipped by THIS worker until a restart or a new generation and nothing is written to the store, and a resume that rejects without settling is re leased on every sweep with no attempt counter and no backoff.
- It authenticates nobody and isolates nothing: no network surface, no executor, permission layer, worktree, or container of its own.
- Retention is the host's predicate; absent, everything persists.
- The lease protocol is the store's: the ttl match is verified only over a store exposing
leaseTtlMs, stale meta and blob writes are rejected only over a store declaringfencedWrites(the journal is fenced always), and the worker adds no fencing of its own. - It observes events and persists none:
onEventsees the stream, nothing is exported, the journal stays the record. - The recorded postures (
strictPricing,clampTurnToExposure,budgetPolicy, the scope with its normalization table, the fingerprint) are restored fromRunMetaby the engine; the worker neither re arms nor checks them, andresumeOptions.runis the one door that changes a ceiling.
Parameters
| Parameter | Type |
|---|---|
engine | Engine |
options | CreateWorkerOptions |