agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
47 lines (46 loc) • 2.19 kB
TypeScript
/**
* search/door — which result door a search tool's value came through, and the
* facts composition reads off it.
*
* Pattern: one pure reader over the three doors a tool returns through —
* `absent()`, `coverage()`, `describedResult()` — by their own
* recognizers. No fourth door.
* Role: semantics/ layer, pure.
* Emits: N/A.
*
* A search tool's coverage comes from its declaration, so a result that ALSO
* hand-writes a `checked` list is declined (`checked-beside-declared`): the
* library reads it as written, files today's row, and composes nothing — a
* row it did not compose establishes nothing. A `coverage()` wrapped around
* `absent({ checked: 'declared' })` is refused: the declaration is the
* boundary, so the absence is returned on its own.
*/
import { type DeclaredPeriod } from '../period.js';
import type { CoverageItem, DeclaredCoveredResult, DeclaredToolAbsence } from '../types.js';
import { type PagingDeclaration, type ResolvedDeclaration } from './resultFacts.js';
/** The facts one door carries, as composition reads them. */
export interface DoorFacts {
readonly door: 'declared-absence' | 'declared-coverage' | 'described' | 'coverage';
/** How many rows came back; `undefined` when they cannot be counted. */
readonly rows: number | undefined;
readonly resolved?: readonly ResolvedDeclaration[];
readonly paging?: PagingDeclaration;
readonly period?: DeclaredPeriod;
readonly handNotChecked: readonly CoverageItem[];
readonly handCannotCover: readonly CoverageItem[];
/** The envelope to compose in place of — present for the two `'declared'` doors. */
readonly absence?: DeclaredToolAbsence;
readonly ledger?: DeclaredCoveredResult;
}
/** What a value is, to a search tool's composition. */
export type DoorReading = {
readonly outcome: 'door';
readonly facts: DoorFacts;
} | {
readonly outcome: 'checked-beside-declared';
};
/**
* Read `value` as one of the three doors, or `undefined` when it is none of
* them (plain data: nothing is composed).
*/
export declare function readSearchDoor(value: unknown, toolName: string): DoorReading | undefined;