UNPKG

agentfootprint

Version:

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

79 lines • 3.59 kB
/** * coverage/timeLimitFacts — WHAT the time layer's limits lines of one turn * say (step T8), read from the record and not yet rendered: the clock's zone, * the turn's `period` rows whose result checks hold, and the wall-clock * sources. * * Pattern: Walker over the committed ledger; pure, no rendering. * Role: the record half of `timeLimits.ts`, split out BY FILE for the one * synchronous door that needs it — the Tools mount's `inputMapper` * (`agent/buildAgentChart.ts` · `timeLimitsArg`), which runs before * any `import()` can: it hands these facts across, and the slot's * served line renders them (`arguments/serve.ts` · `timeLimitsLine`, * loaded under the arm). The renderer (`time/present.ts`) never * reaches the graph `import { Agent }` loads (the optional-family * law, `test/trace-toolpack/browserGraph.test.ts`). * Emits: N/A. * * `undefined` exactly when `timeLimits.ts` · `renderTimeLimits` would say * nothing for the same audience — so the mount arg stays value-conditional: * a turn whose reads match what was asked crosses no key. * * @example * ```ts * timeLimitFactsOf(ledger, 1, 'model'); * // { zone: 'America/Los_Angeles', period: [{ kind: 'period', differs: { … }, … }], sources: [] } * ``` */ import { clockOf, presentationZoneOf, sourceClocksOf } from '../../time/rows.js'; import { clocksDiffer, distinctSources, } from '../../time/checkRecord.js'; /** * Whether a `period` row carries a limits line for `audience`: a read that * differs, a shifted look-back, or a window beyond retention (`period.ts` · * `periodCheckLine` returns one exactly then) — and, for the MODEL only, a * source that holds none or only part of the asked time (`held`, rendered by * `timeLimits.ts` · `heldLine`). The person's limits block already prints that * span on the call's `Period:` line (`period.ts` · `periodLine`), in their * zone, so it gets no second line. */ export function carriesCheckLine(row, audience = 'person') { return (row.differs !== undefined || row.shifted !== undefined || row.beyondRetention === true || (audience === 'model' && row.held !== undefined)); } /** * The turn's limits facts from the ledger. `turn` undefined reads every row * (a ledger that carries one turn). `undefined` when there is no clock or, * for this `audience`, nothing to say: the person reads every wall-clock * source, the model only the label that two differ. */ export function timeLimitFactsOf(ledger, turn, audience = 'person') { const zone = presentationZoneOf(ledger); if (zone === undefined || ledger === undefined) return undefined; const zoneUnknown = clockOf(ledger)?.zoneSource === 'unknown'; const period = []; for (const row of ledger) { const r = row; if (r === null || typeof r !== 'object' || r.kind !== 'period') continue; if (turn !== undefined && r.turn !== turn) continue; if (carriesCheckLine(row, audience)) period.push(row); } const sources = distinctSources(sourceClocksOf(ledger, turn)); const differ = clocksDiffer(sources); const clocks = audience === 'person' ? sources.length > 0 : differ !== undefined; if (period.length === 0 && !clocks) return undefined; return { zone, period, sources, ...(differ !== undefined && { differ }), ...(zoneUnknown && { zoneUnknown: true }), }; } //# sourceMappingURL=timeLimitFacts.js.map