Skip to main content

Module dispatch

Module dispatch 

Source
Expand description

Module fan-out under deadlines, with an exit-0 contract.

Mirrors @rightkit/hooks dispatchHookEvent (serial modules in declared order, a typed per-module result, a per-module deadline that defaults to 3000 ms) and adds one total deadline, so two modules on one event share one budget. Nothing a module does can fail the host: an error, a panic or a timeout becomes a typed result, and the reply falls back to nothing.

A module that times out is not killed: Rust cannot stop a thread. Its thread keeps running until the module returns (cooperative modules watch ModuleContext::is_cancelled) and any side effect it has, such as writing a receipt, can still land after the hook has replied.

The only non-zero exit is a module’s explicit Decision::DenyTool on Codex, which is exit 2 with the reason on stderr (Legion’s shipped shape).

Structs§

DispatchOptions
DispatchResult
FnModule
A module from a closure.
ModuleContext
Passed to a module so it can stop early: the deadline, and a flag set once it has passed.
ModuleOutput
ModuleResult

Enums§

Decision
A module’s verdict on the event. Applied only where the event’s schema takes it.
Status

Constants§

DEFAULT_CONTEXT_CAP_BYTES
Merged context cap in bytes (Pulse’s TEXT_CAP).
DEFAULT_MODULE_DEADLINE
Per-module budget, the JS default.
DEFAULT_TOTAL_DEADLINE
Whole-dispatch budget, inside the 10 s timeout the Pulse plugins register.

Traits§

HookModule

Functions§

compose_reply
Merge module outputs into the one reply the event’s schema allows.
dispatch
Run modules in order. Each gets min(module_deadline, what is left of total_deadline); once the total is spent the rest are recorded as errors and not started.
run
run_with on the process’s own stdin, stdout and stderr.
run_with
The whole hook process over arbitrary streams. Returns the exit code: 0 on every failure.