oracular / explain
Function: explain()
ts
function explain(
state,
intent,
at,
opts?
): SignalExplanation[];Defined in: explain.ts:30
Why the intent's p is what it is at time at: one entry per declared signal, the ones that matter most first. contribution is the signed pseudo-count the signal currently holds after decay, impact is how much p would change if that contribution were removed, and the three weights show what the developer said, what this user's history says, and what the next occurrence will actually add. Read-only.
Parameters
| Parameter | Type | Description |
|---|---|---|
state | EngineState | The current state. Not mutated. |
intent | string | Name of an intent declared in the config. |
at | number | The time to evaluate at; contributions and learned counts are decayed to it. |
opts? | ExplainOptions | Optional filters: nonZero keeps only signals that currently hold evidence, limit caps the number of rows. Default: every declared signal. |
Returns
One SignalExplanation per declared signal, sorted by |impact| descending, then by name, then filtered by opts. Empty for an intent that declares no signals.
Throws
RangeError when intent is not declared in the config.
Throws
TypeError when state is not an engine state, at is not finite, or opts is malformed.
Example
ts
for (const row of explain(state, 'upgrade', Date.now(), { nonZero: true })) {
console.log(row.signal, row.impact.toFixed(2), row.effectiveWeight.toFixed(2));
}