UNPKG

agentfootprint

Version:

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

47 lines • 2.58 kB
"use strict"; /** * coverage — what a run's records are served under, as a typed value with * THREE states. `undefined` is never "no policy". * * Pattern: a closed discriminated union, decided where the library positively * knows the answer and switched on wherever a record is served. * Role: the one vocabulary every serving door resolves to * (`runRedaction.ts` · `coverageOfExecutor`, `declared.ts` · * `declarationOf`, `EventDispatcher` · `served`): * * - `covered` — the run was opened with a policy: serve under it. * - `declared-none` — POSITIVELY known to have none: the run was opened by * this library with no policy, or the runner declared * none when it was built. Served unchanged. * - `unknown` — the executor, the run, the scope or the runner is not * one this library recorded: nothing says what its * records may show. FAIL CLOSED, whatever the instance * declares — a placeholder for an event, a refusal for * a snapshot or a record. * * A lookup that misses is `unknown`, never `declared-none`: the difference * between "this run had no policy" and "this run is not one we know" is the * difference between serving a record and serving another run's raw values. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.policyOfCoverage = exports.coverageOfOpenedRun = exports.UNKNOWN_COVERAGE = exports.DECLARED_NONE = void 0; /** Positively no policy. */ exports.DECLARED_NONE = Object.freeze({ state: 'declared-none' }); /** Not recorded by this library — fail closed. */ exports.UNKNOWN_COVERAGE = Object.freeze({ state: 'unknown' }); /** * The coverage of a run THIS library opened, from the policy it computed for * the run — the union of typed declarations and the policies handed to the * run. Here, and only here, an absent policy is a positive fact: every input * of the union was itself known. */ function coverageOfOpenedRun(policy) { return policy === undefined ? exports.DECLARED_NONE : Object.freeze({ state: 'covered', policy }); } exports.coverageOfOpenedRun = coverageOfOpenedRun; /** The policy a coverage serves under — `undefined` for `declared-none` only; `unknown` has none to give. */ function policyOfCoverage(coverage) { return coverage.state === 'covered' ? coverage.policy : undefined; } exports.policyOfCoverage = policyOfCoverage; //# sourceMappingURL=coverage.js.map