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.33 kB
"use strict"; /** * integrityFindings — the ONE rail every Context Integrity finding is filed * on, whichever stage detected it. * * Pattern: a tiny impure helper over tracked scope; no state of its own. * Role: identity dedup across passes AND across stages. One defect emits * ONE `agentfootprint.integrity.context_error` per run, however many * calls, iterations or seams re-detect it. * * WHY IT IS A MODULE AND NOT A LOCAL FUNCTION. It lived inside `callLLM` while * every seam that filed findings lived there too, with its own header saying * "a second copy of this loop would eventually disagree with the first about * what 'already filed' means". 9.77.0 put a check at a second STAGE — the * write seam runs at the tool-dispatch boundary, where a result exists — and * a second copy is exactly what that would have meant. The rail moved instead. * * The seen-list is `scope.integrityFindingIds`, falling back to * `priorIntegrityFindingIds` (a resumed run's carried list) — freshest copy * first, since a stage may have extended the list earlier in the same pass. * The identity is computed with the EPOCH STRIPPED, so the same defect on a * later iteration is the same defect. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.fileIntegrityFindings = void 0; const typedEmit_js_1 = require("../../recorders/core/typedEmit.js"); const types_js_1 = require("../../integrity/finding/types.js"); /** File findings on the shared seen-list rail, one event per new identity. */ function fileIntegrityFindings(scope, findings, iteration) { if (findings.length === 0) return; const seenIds = scope.$getValue('integrityFindingIds') ?? scope.$getValue('priorIntegrityFindingIds') ?? []; const newIds = [...seenIds]; for (const f of findings) { const id = (0, types_js_1.contextErrorIdentity)({ ...f, epoch: undefined }); if (newIds.includes(id)) continue; newIds.push(id); (0, typedEmit_js_1.typedEmit)(scope, 'agentfootprint.integrity.context_error', { ...f, iteration }); } if (newIds.length > seenIds.length) scope.$setValue('integrityFindingIds', newIds); } exports.fileIntegrityFindings = fileIntegrityFindings; //# sourceMappingURL=integrityFindings.js.map