UNPKG

agentfootprint

Version:

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

35 lines • 1.8 kB
/** * isJsonFaithful — does JSON write this value down faithfully? * * Role: Fold. A leaf predicate: it reads its argument and nothing else. * Reads: its argument. * Emits: N/A. * * True when `JSON.parse(JSON.stringify(value))` gives back the same value — * the question a binding has to ask before it fingerprints a value with * `canonicalJson`, which (by design, for the audit chain) writes a `Date` as a * string, a `Map` as `{}` and `NaN` as `null`. Two different values that JSON * writes the same way would fingerprint the same, so a binding over them would * match what it never saw. This predicate is how such a value is refused by * its DOMAIN instead. * * Faithful: `null`, booleans, strings, finite numbers, dense arrays of * faithful values, and plain objects (prototype `Object.prototype` or `null`, * string keys, data properties) whose values are faithful. * * JSON's own two equivalences are accepted, because JSON is what a person is * shown and what a stored checkpoint holds: a property whose value is * `undefined` reads back as absent, and `-0` reads back as `0`. * * Not faithful: `undefined` at the top or in an array, `NaN`, `±Infinity`, * `bigint`, symbols, functions, a `Date`, `Map`, `Set`, `RegExp`, `Error`, * typed array or any class instance, an array with holes or a named property, * an object with a symbol key or an accessor property, a cycle, or nesting deeper than * {@link MAX_JSON_DEPTH}. A shared (non-cyclic) reference is fine. * * Never throws: a value it cannot read is not faithful. */ /** Nesting deeper than this is refused — a depth a tool's arguments never reach. */ export declare const MAX_JSON_DEPTH = 100; export declare function isJsonFaithful(value: unknown): boolean; //# sourceMappingURL=jsonFaithful.d.ts.map