agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
72 lines • 3.32 kB
JavaScript
;
/**
* 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.honestyLayersOf = exports.readInputsLayerOption = void 0;
/**
* `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.
*/
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 } : {};
}
exports.readInputsLayerOption = readInputsLayerOption;
/**
* 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
* ```
*/
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 }),
};
}
exports.honestyLayersOf = honestyLayersOf;
//# sourceMappingURL=armed.js.map