UNPKG

agentfootprint

Version:

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

65 lines (64 loc) • 3.48 kB
/** * ontology/serve — the map served as one request-only system piece. * * Pattern: one pure function over the committed spec (the twin of * `findings/serve.ts · findingsLedgerPiece`): no scope, no I/O, no * clock, no call number. Same spec, same bytes. * Role: Lens. `ontologyPiece` composes the piece `callLLM · * buildCallLLMStage` joins AFTER the recovery piece and BEFORE the * findings piece (injections → recovery → ontology → findings, * FIXED) and `servedView.ts · viewOf` recomposes from the run * constant `ontology` in the same slot, so the receipt agrees by * construction. It is never pushed into `systemPromptInjections` * (a piece there is exempt from the evidence gate) and never a * `history` turn. * Emits: N/A (the stage emits `agentfootprint.ontology.served`). * * THE LAW OF THE PIECE * Every line quotes the declaration. The header is a CONSTANT that names * what the piece is, what the framework did NOT do, and the three context * contract meanings the map is the data behind (`lib/context-contract · * CONTEXT_FIELD_MEANINGS`, one owner, quoted never restated); every other * line is a node, a source, a holding, a relation or an id list, rendered * from the author's own strings. No sentence the library wrote about the * domain. The library never decides that a node "has no data": a node with * no declared source is listed as `known, not held here`, which is what * the author said, not a verdict. * * THE CACHE * The piece joins the ONE system block a cache marker covers * (`findings/serve.ts` · "The cache"), so it carries no byte that is not a * function of the spec: an unchanged map is served unchanged on every call * of the run and reuses the cached prefix. * * BOUNDS * `ONTOLOGY_PIECE_LIMITS.sectionLines` lines per section and * `listedIds` ids on the id line, every overflow STATED (`+K more`); an * empty section is omitted, never rendered as "no relations". Every * author string is folded onto one line (`define.ts` already bounds its * length), so no declaration can open a line — or a section — the piece * never counted. Nodes and sources are rendered sorted by id, so two * specs that hash the same (`ontologyHash` is key-order independent) * serve the same bytes; edges keep declaration order, as the hash does. */ import type { OntologyJoin, OntologySpec } from './types.js'; /** The request-only system piece; `source: 'ontology'` names it on the receipt. */ export interface OntologyPiece { readonly rawContent: string; readonly slot: 'system-prompt'; readonly source: 'ontology'; } /** The bounds of the piece. Overflow past either is stated in the text. */ export declare const ONTOLOGY_PIECE_LIMITS: Readonly<{ /** Lines per section (nodes, sources, held by, relations) before `+K more`. */ readonly sectionLines: 64; /** Ids on the `known, not held here` line before `+K more`. */ readonly listedIds: 64; }>; /** * Compose the ontology piece for one request. Shared by the live request * assembly and the served-view rebuild; the bytes are a function of the spec * and the join (9.108.0: the record's tool → skills map and the request's * hidden skill ids) and nothing else. No join, the 9.106.0 bytes. */ export declare function ontologyPiece(spec: OntologySpec, join?: OntologyJoin): OntologyPiece;