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§
- Dispatch
Options - Dispatch
Result - FnModule
- A module from a closure.
- Module
Context - Passed to a module so it can stop early: the deadline, and a flag set once it has passed.
- Module
Output - Module
Result
Enums§
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§
Functions§
- compose_
reply - Merge module outputs into the one reply the event’s schema allows.
- dispatch
- Run
modulesin order. Each getsmin(module_deadline, what is left of total_deadline); once the total is spent the rest are recorded as errors and not started. - run
run_withon 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.