UNPKG

agentfootprint

Version:

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

62 lines • 3.29 kB
/** * ontology/define — `defineOntology`: validate a declaration, detach it, * freeze it, fingerprint it. * * Pattern: one pure function over plain JSON plus one pure hash; no I/O, * no registry (the tool names in `via` are checked where the * registry exists — `Agent.ts · buildChart`, beside * `buildToolRegistry` — so `.build()` is what refuses them). * Role: Map. It decides nothing about what the model sees; it decides * whether a declaration is well-formed enough to be served as data. * Emits: N/A. * * THE LAWS * - Every fault is refused by NAME at definition time, never repaired: an * edge to a node that does not exist, a node held by a source that was * never declared, an id that is not identifier-safe, a text that is * empty or longer than a served line may carry. A declaration that * reaches an agent is one every served line can quote whole. * - `configured` is copied only when the author wrote it. Absent stays * absent; the served line then says nothing about configuration * (`serve.ts`). The library never assumes a source is wired. * - The result is detached (rebuilt from the input, never aliased) and * deep-frozen, so a later edit of the caller's objects cannot move what * `seed` puts on the record. * - `ontologyHash` fingerprints the FIVE declared fields through the * receipt's own canonical JSON (`stableJson.ts · stableJson` — keys sorted, * `undefined` dropped — one owner of the rule) and `sha256Hex`: two * declarations that differ only in key order hash the same; edge order * is declaration order and is part of the identity. */ import type { Ontology, OntologySpec } from './types.js'; /** The bounds a declaration must fit — each one is what keeps a served line one line. */ export declare const ONTOLOGY_LIMITS: Readonly<{ /** Chars per id (`id`, a node key, a source key). */ readonly idChars: 64; /** Chars per text (`meaning`, `unit`, `coverage`, an alias, a relation, `version`). */ readonly textChars: 512; readonly nodes: 256; readonly sources: 64; readonly edges: 512; /** Aliases on one node — and, since 9.109.0, on one source. */ readonly aliasesPerNode: 16; readonly sourcesPerNode: 8; readonly viaPerSource: 16; }>; /** * Validate a declaration and return it detached, frozen and fingerprinted. * Throws a `TypeError` naming the first fault found. The registered-tool * check on `via` happens at `Agent` build, where a registry exists. */ export declare function defineOntology(spec: OntologySpec): Ontology; /** * The declaration's fingerprint: SHA-256 (64 hex) over the canonical JSON * of `{ id, version, nodes, sources, edges }` — the receipt's `stableJson`, * so key order never moves it. `hash` on an `Ontology` is never an input. * Defined over a VALIDATED spec: called on a raw spec that `defineOntology` * would refuse (an unknown key, a bad shape), the hash still includes * whatever that raw spec carries, so `ontologyHash(raw) === defineOntology(raw).hash` * holds only once the spec is one `defineOntology` accepts. */ export declare function ontologyHash(ontology: OntologySpec): string; //# sourceMappingURL=define.d.ts.map