agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
69 lines (68 loc) • 4.05 kB
TypeScript
/**
* honesty/sourceCorpus — the calls' declared sources (`declaredSourcesOf`) and
* the corpora the inputs layer's checks read (`sourceCorpusOf`), built from
* the batch and the pieces the mount handed in.
*
* Pattern: one pure builder. Every corpus is read the way its one owner reads
* it: the person's messages through `lib/saidByPerson.ts` · `isSaidByPerson`,
* a result through `findings/offer.ts` · `isResultMessage` and its TOOL bytes
* through `lib/toolBytes.ts` · `toolBytesOf`, the model's current standing
* through `findings/ledger.ts` · `foldLedger`, this batch's own standings
* through `findings/reserved.ts` · `readDeclaration`.
* Role: core/agent/honesty — the one module on the layer's side that may
* import BOTH `findings/` and `arguments/` (the one-way law keeps
* `arguments/` a leaf). Loaded through `import()` by the mount's
* closures on first use (`mounts.ts` · `buildInputsSubflow`), only
* under declared sources (`.findings({ argumentSources: true })` or
* `.inputsLayer({ argumentSources: true })`) — never on a plain
* agent's graph.
* Emits: N/A.
*
* ## What counts, and what never does
*
* - **The person's words**: every served message a person wrote, the current
* request included, within the window. In a COMPOSED run
* (`AgentInput.messageFrom: 'composed'`) the run's own message is marked:
* it is another runner's output, never the person's.
* - **A result**: its tool's own bytes, cut at the tool-bytes boundary, so a
* library note never speaks for the tool; an id known only through the
* previous batch has no cut to read through and carries no text.
* - **The app's text**: `role: 'system'` history messages, the composed
* system prompt's records (raw content, or the summary a redacted record
* carries — the evidence gate's own reach, which includes memory recall and
* retrieval passages, adopted Q15), and the app's `externalGrounds` with
* their labels. The library's own always-on instructions (the findings
* ledger's, the ontology's) are left out: library text is never evidence.
* - **The person's answers**: the ledger's `answered` argument rows — the
* ask writes no message, so they live on the ledger, and compaction never
* evicts them.
* - **Assistant text** only to say a value was found nowhere else.
*/
import type { ExternalGround } from '../../../integrity/unsupported-argument/check.js';
import type { SourceCorpus } from '../arguments/checks.js';
import type { BatchCall, ToolOf } from '../arguments/resolve.js';
import type { CallSources } from '../arguments/sources.js';
import type { SourceInputs } from '../arguments/subflow.js';
/**
* Each call's declared sources, through the ONE reader of `_findings`
* (`findings/reserved.ts` · `readDeclaration`, under the sources arm), judged
* against the call's own arguments. A call whose tool OWNS the reserved
* argument declares nothing and gets no entry; a call with no `_findings`
* declares an empty `from`. The dropped entries' count rides only when the
* call files no basis row (that row carries it otherwise) — and a call files
* one only beside the findings ledger (`options.basisRows`: `.findings()` is
* armed and the call declared a basis). Declared sources without the ledger
* file no basis row at all, so the count always rides the first argument row.
*/
export declare function declaredSourcesOf(calls: readonly BatchCall[], toolOf: ToolOf, options?: {
readonly basisRows?: boolean;
}): readonly CallSources[];
/**
* The corpora the declared-sources checks read, for one batch — built from
* the raw pieces the mount handed in (`SourceInputs`), the batch itself (its
* own `previous[]` standings) and the app's `externalGrounds`.
*/
export declare function sourceCorpusOf(inputs: SourceInputs, calls: readonly BatchCall[], turn: number, deps: {
readonly toolOf: ToolOf;
readonly externalGrounds?: () => readonly ExternalGround[];
}): SourceCorpus;