UNPKG

agentfootprint

Version:

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

49 lines • 2.08 kB
/** Checkpoint admission for observe-only prose findings. No prose or evidence is * re-judged on restore, and an unknown/malformed row cannot silently disappear. */ import { PROSE_NOTES } from '../../../integrity/negative-claim/types.js'; import { copyJson } from '../../../lib/boundedJson.js'; export function negativeProseRowIsWellFormed(value) { try { const row = 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) => 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; } } //# sourceMappingURL=negativeProse.js.map