UNPKG

agentfootprint

Version:

The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.

58 lines (57 loc) • 3.31 kB
/** * The three checks, their signals, what could not be run, the "Anything wrong" * row and the one-liner. * * Signals, not causes: each signal is a record fact under a fixed rule; the * account never assigns fault. PRIORITY (the order signals are listed and the * one-liner quotes them): * 1. decided-delivered — `decided-not-delivered` (bad) * 2. existence — `existence-not-checked`, from a `notChecked` OR a * `cannotCover` item with `kind: 'existence'` (warn) * 3. empty-results — `undeclared-empty-used` (bad), then * `undeclared-empty-in-view` (warn) * The disposition law: a check that could not run is NOT "nothing wrong" — it * is listed as unreachable, and a check that does not apply to this answer is * left out of the count (`reachable + unreachable + notApplicable = 3`). */ import type { CheckId, RecordPointer, Sentence, Signal, Unreachable } from './types.js'; import { type ReadContext } from './facts/common.js'; import { type CallsRead } from './facts/calls.js'; import type { PausedLegRead } from './facts/pausedLeg.js'; import type { InViewAll } from './facts/inView.js'; import type { UnderstoodRead } from './facts/understood.js'; /** Signal lines per check, and unreachable lines per check, before the rest are counted. */ export declare const MAX_LINES_PER_CHECK = 3; export interface ChecksRead { readonly signals: readonly Signal[]; /** Signal and unreachable lines past `MAX_LINES_PER_CHECK`, counted, not listed. */ readonly omitted: number; /** Of `omitted`, how many were SIGNALS — the signal count is a fact, so it counts them too. */ readonly omittedSignals: number; readonly omittedPointers: readonly RecordPointer[]; readonly unreachable: readonly Unreachable[]; readonly reachable: readonly CheckId[]; readonly unreachableChecks: readonly CheckId[]; readonly notApplicable: readonly CheckId[]; /** Pointers behind the checks that ran (for "found nothing"). */ readonly checkPointers: readonly RecordPointer[]; /** A resumed leg of a routed agent whose routing verdict neither an event nor the paused state holds. */ readonly routingLost: boolean; } export declare function runChecks(ctx: ReadContext, understood: UnderstoodRead, calls: CallsRead, inView: InViewAll, /** The part before a pause, read from the committed state (`facts/pausedLeg.ts`) — judged like this leg's calls. */ pausedLeg?: PausedLegRead): ChecksRead; /** The "Anything wrong" row's lines, in order. */ export declare function wrongLines(ctx: ReadContext, checks: ChecksRead, calls: CallsRead, pausedLeg?: PausedLegRead): Sentence[]; export interface SummaryRead { readonly sentence: Sentence; readonly tone: 'ok' | 'warn' | 'bad' | 'unknown'; } /** * The one-liner. On a resumed leg whose record holds the committed state, the * checks above read the part before the pause from it, so the one-liner is * the one any answer gets, followed by what this record does NOT hold of the * part before the pause (its events). Only a record with no committed history * says the part before the pause is not in it. */ export declare function summaryOf(ctx: ReadContext, checks: ChecksRead, finished: boolean, pausedLeg?: PausedLegRead): SummaryRead;