UNPKG

agentfootprint

Version:

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

45 lines • 1.63 kB
"use strict"; /** * window/removal — "these messages left" → the facts the ledger needs. * * Pattern: Pure function over the meter's provenance. * Role: core/ layer. The stage binds this into every * `WindowStrategyInput.removalFacts`, so a strategy can name what it * removed without ever touching the meter — and cannot file a * removal it is unable to name. * Emits: N/A. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.indexRange = exports.removalFacts = void 0; /** * Resolve which stages wrote the removed messages, and how long each lived. * * `survivalMs` is measured (`atMs - bornAtMs`), and is 0 — not a guess — when * a message's birth is unknown, which happens only for a window seeded from * outside this run. */ function removalFacts(origins, indices, atMs) { const removedStageIds = []; const evictions = []; for (const index of indices) { const origin = origins[index]; if (origin !== undefined && !removedStageIds.includes(origin.stageId)) { removedStageIds.push(origin.stageId); } evictions.push({ index, survivalMs: origin === undefined ? 0 : Math.max(0, atMs - origin.bornAtMs), }); } return { removedStageIds, evictions }; } exports.removalFacts = removalFacts; /** `[from, toExclusive)` as a list of indices. */ function indexRange(from, toExclusive) { const out = []; for (let i = from; i < toExclusive; i++) out.push(i); return out; } exports.indexRange = indexRange; //# sourceMappingURL=removal.js.map