ExecutionInput
EnvironmentModule.execute:
eidis the execution id. It is the same number as the processpid. Treat it as opaque; just feed it back to every binding.codeis exactly what the client submitted viaPOST /processes.envConfigis a generic bag of environment-level configuration set by the host. The host guarantees at minimum atimeoutMskey, resolved againstDEFAULT_EXECUTION_TIMEOUT_MS(30000) before dispatch. The environment should treat this as authoritative and pluck the values it recognises.
Host-side States
The host’sProcessService runs the public-facing state machine. From
the API’s perspective, a process is always in one of four states:
idle: Not executing. Either pre-run, or post-run with an exit state.queued: Accepted, waiting for the environment.running: Environment is executing the code.terminating: A kill is in flight.
Environment-reported States
EnvironmentBindings.setState(eid, data) accepts only the environment
states:
idle and terminating
are host-only; the environment never reports them.
Exit States
execute returns one of these. The host stores it as
process.exitState:
The host also accepts
null as a transient pre-execution value, but
environment code never returns null.
Timeout Contract
The host hands the environment atimeoutMs within envConfig and
expects the environment to enforce it. The host does not run a wall
clock of its own; if the environment lies about exit state, the process
record lies too.
- The bundled
typescript-ivmenforces the timeout by racing the isolate against asetTimeout, then disposing the isolate. - Custom environments are free to use any mechanism, process group signals, worker thread interrupts, whatever fits the runtime.
Cancellation Contract
EnvironmentModule.kill(eid) is the only way the host asks for
cancellation. The environment should:
- Stop whatever is executing for
eidpromptly. - Resolve the outstanding
execute(eid)promise with"canceled". - Be safe to call with an
eidit does not know about.
AbortController exposed to user code).