HookIngest
Defined in: src/hooks-ingest.ts:193
Bounded in-memory ring buffer + structured logging for ingested hook events. The
single owner of the Phase-0 observable surface. record never throws — a malformed
forward must never crash the request loop.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new HookIngest(
onSignal?):HookIngest
Defined in: src/hooks-ingest.ts:206
Parameters
Section titled “Parameters”onSignal?
Section titled “onSignal?”(sessionId, ev) => void
Returns
Section titled “Returns”HookIngest
Methods
Section titled “Methods”allSubagentsSnapshot()
Section titled “allSubagentsSnapshot()”allSubagentsSnapshot():
Record<string,SubagentEntry[]>
Defined in: src/hooks-ingest.ts:334
Every tracked session’s roster array, keyed by sessionId — for a global bootstrap.
As with subagentSnapshot, the entry objects are internal references but JSON-safe
since SubagentEntry fields are all primitives.
Returns
Section titled “Returns”Record<string, SubagentEntry[]>
prune()
Section titled “prune()”prune(
activeIds):void
Defined in: src/hooks-ingest.ts:341
Drop ring-buffer + roster entries for sessions no longer active (called from the poller’s prune).
Parameters
Section titled “Parameters”activeIds
Section titled “activeIds”Set<string>
Returns
Section titled “Returns”void
record()
Section titled “record()”record(
sessionId,ev):void
Defined in: src/hooks-ingest.ts:252
Push an event, log it, and (only on a matched session) forward to signals.
Parameters
Section titled “Parameters”sessionId
Section titled “sessionId”string
Returns
Section titled “Returns”void
setSink()
Section titled “setSink()”setSink(
onSignal):void
Defined in: src/hooks-ingest.ts:217
Set (or clear) the Phase-1 signal sink AFTER construction. index.ts constructs the
HookIngest before the poller (the poller’s prune callback needs it), then wires the
sink once the poller exists — resolving the circular construction order without a
forward-declared let. The ctor onSignal arg still works (Task 2 tests use it);
this just lets the wiring happen post-construction when config.hooksSignals is on.
Parameters
Section titled “Parameters”onSignal
Section titled “onSignal”(sessionId, ev) => void
Returns
Section titled “Returns”void
setSubagentSink()
Section titled “setSubagentSink()”setSubagentSink(
cb):void
Defined in: src/hooks-ingest.ts:226
Set (or clear) the Phase-3 sub-agent roster sink AFTER construction — mirror of setSink. A later task wires this so a roster change pushes the updated array (e.g. to the UI). Left unwired here ⇒ the roster is tracked but not pushed.
Parameters
Section titled “Parameters”(sessionId, roster) => void
Returns
Section titled “Returns”void
snapshot()
Section titled “snapshot()”snapshot(
sessionId):HookEvent[]
Defined in: src/hooks-ingest.ts:313
A copy of the session’s ring buffer (or []), safe to hand to a JSON response.
Parameters
Section titled “Parameters”sessionId
Section titled “sessionId”string
Returns
Section titled “Returns”subagentSnapshot()
Section titled “subagentSnapshot()”subagentSnapshot(
sessionId):SubagentEntry[]
Defined in: src/hooks-ingest.ts:324
The session’s sub-agent roster as an array (insertion order; [] if none).
The array is fresh, but the entries are the internal SubagentEntry references;
safe to hand to a JSON response because every field is a primitive (no nested
objects to alias), mirroring snapshot().
Parameters
Section titled “Parameters”sessionId
Section titled “sessionId”string