agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
53 lines • 2.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.negativeProseRowIsWellFormed = void 0;
/** Checkpoint admission for observe-only prose findings. No prose or evidence is
* re-judged on restore, and an unknown/malformed row cannot silently disappear. */
const types_js_1 = require("../../../integrity/negative-claim/types.js");
const boundedJson_js_1 = require("../../../lib/boundedJson.js");
function negativeProseRowIsWellFormed(value) {
try {
const row = (0, boundedJson_js_1.copyJson)(value, 1024 * 1024, true);
const integer = (v) => typeof v === 'number' && Number.isSafeInteger(v) && v >= 0;
const strings = (v) => Array.isArray(v) && v.every((item) => typeof item === 'string');
const span = row.span;
if (typeof row.field !== 'string' ||
typeof row.packVersion !== 'string' ||
!integer(row.iteration) ||
!integer(row.turn) ||
row.turn < 1 ||
!span ||
!integer(span.start) ||
!integer(span.end) ||
span.end < span.start)
return false;
if (row.kind === 'negative-claim-note')
return ([
'in-code-block',
'language-unsupported',
'too-many-claims',
'input-limit',
'no-read',
].includes(row.code) &&
(row.phraseId === undefined || typeof row.phraseId === 'string'));
if (row.kind !== 'negative-claim' ||
!['none', 'complete'].includes(row.claim) ||
typeof row.phraseId !== 'string' ||
!strings(row.notes) ||
!row.notes.every((note) => types_js_1.PROSE_NOTES.includes(note)) ||
!strings(row.results) ||
(row.candidates !== undefined && !strings(row.candidates)))
return false;
const stale = row.staleSince;
return (stale === undefined ||
(stale !== null &&
integer(stale.turn) &&
stale.turn > 0 &&
(stale.readAt === undefined || typeof stale.readAt === 'string')));
}
catch {
return false;
}
}
exports.negativeProseRowIsWellFormed = negativeProseRowIsWellFormed;
//# sourceMappingURL=negativeProse.js.map