UNPKG

agentfootprint

Version:

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

67 lines • 3.1 kB
/** * honesty/armed — which honesty layers a run has armed: the ONE run constant. * * Pattern: a run constant, seeded once by `stages/seed.ts` (the * `findingsServe` precedent) and never written again during the run. * Role: core/ layer leaf. A reader of the RECORD — the standing fold, a * lens, a bench — tells "this layer was armed and filed nothing" from * "this layer was never armed" by this key alone, never by guessing * from the rows. * Emits: N/A. * * Absent on a run with no layer armed, so an agent that armed nothing commits * exactly the keys it always did. */ /** * `AgentOptions.inputsLayer` as the agent reads it — `undefined` when the * layer is not asked for (`undefined` or `false`), the options otherwise * (`true` reads as `{}`). Anything else is REFUSED, naming the value: a door * that silently ignored `{ argumentSources: 'yes' }` would look configured and * do nothing. */ export function readInputsLayerOption(value) { if (value === undefined || value === false) return undefined; if (value === true) return {}; if (typeof value !== 'object' || value === null || Array.isArray(value)) { throw new Error(`Agent: inputsLayer must be true, false or { argumentSources?: boolean }, got ` + `${JSON.stringify(value)}.`); } const unknown = Object.keys(value).filter((k) => k !== 'argumentSources'); if (unknown.length > 0) { throw new Error(`Agent: inputsLayer takes { argumentSources?: boolean } only — unknown key ` + `${unknown.map((k) => `'${k}'`).join(', ')}.`); } const sources = value.argumentSources; if (sources !== undefined && typeof sources !== 'boolean') { throw new Error(`Agent: inputsLayer.argumentSources must be true or false, got ${JSON.stringify(sources)}.`); } return sources === true ? { argumentSources: true } : {}; } /** * The run constant for an agent's armed layers, or `undefined` when none is * armed (then seed writes nothing). A layer that is not armed is absent from * the object — never `false` — so the bytes of a run that armed only the * inputs layer are the bytes that layer has always committed. * `argumentSources` only beside `inputs`. * * @example * ```ts * honestyLayersOf({ inputs: true, answer: false }); // { inputs: true } * honestyLayersOf({ inputs: true, argumentSources: true, answer: false }); // { inputs: true, argumentSources: true } * honestyLayersOf({ inputs: false, results: true, answer: false }); // { results: true } * honestyLayersOf({ inputs: false, answer: false }); // undefined * ``` */ export function honestyLayersOf(armed) { if (!armed.inputs && armed.results !== true && !armed.answer) return undefined; return { ...(armed.inputs && { inputs: true }), ...(armed.inputs && armed.argumentSources === true && { argumentSources: true }), ...(armed.results === true && { results: true }), ...(armed.answer && { answer: true }), }; } //# sourceMappingURL=armed.js.map