UNPKG

agentfootprint

Version:

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

45 lines (44 loc) • 2.53 kB
/** * classifierScorer — an {@link EntryScorer} whose ranking IS a calibrated * classifier's distribution (9.104.0; docs/design/2026-09-scored-choice.md * step 2, opened when a provider that scores came in reach). * * `keywordScorer` and `embeddingScorer` compute a raw score per candidate * and let `rankEntries` soften it into a `relevance` share. This scorer has * no raw score to soften: the classifier is asked ONE `choice` question * over the candidates — criteria `{ id: description }`, declared before the * call, the same law as declared tags and routes — and answers with a * probability per candidate and a pick. Both are the provider's data and * both land on `EntryScoring` unchanged: `ranked[].score` and * `ranked[].relevance` are the SAME number (the probability as sent, never * renormalised), and `chosen` is the provider's `choice`, not an argmax the * library took — a provider whose pick differs from its own argmax is * recorded as it answered, which is a fact about the provider. * * A provider failure is NOT a guess: the scorer returns * `scorer: 'classifier:unavailable'`, an EMPTY ranking and no `chosen`. * `stages/pickEntry.ts` leaves the cursor unset on an undefined `chosen` * and the Injection Engine's cold-start entry pick takes over — the * fallback that already exists for a throwing embedder, reached here * through the honest empty result rather than a throw. * * Pure core of the skill-graph fence: the only import outside the folder * is the `Classifier` port type (`src/classify/types.ts`, a zero-import leaf). */ import type { Classifier } from '../classify/types.js'; import type { EntryScorer } from './entryScorer.js'; export interface ClassifierScorerOptions { /** The instruction on the choice question. Default: pick the skill the message is for. */ readonly instructions?: string; } /** The question id every scoring asks under — fixed, so a record reader can find it. */ export declare const CLASSIFIER_SCORER_QUESTION: "entry"; /** The `scorer` name on an unavailable result. */ export declare const CLASSIFIER_SCORER_UNAVAILABLE: "classifier:unavailable"; /** * `classifierScorer(classifier)` — plug into `skillGraph().entryBy(...)`. * `scorer` on a scoring is `'classifier:' + the provider's model string` * (`'classifier:jev-1.13.0'`), so the "Why this skill?" panel names the * exact model that ranked. */ export declare function classifierScorer(classifier: Classifier, options?: ClassifierScorerOptions): EntryScorer;