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 (52 loc) • 2.63 kB
TypeScript
/**
* invariant-violation — two things that cannot both be true were both
* asserted, caught at the WRITE that created the contradiction.
*
* Pattern: pure function over one write-delta plus the standing set.
* Role: the first Context Integrity check, and the cheapest. When a
* map's engagement is written PARKED while tools it owns are
* still on the wire, the two channels disagree: one says the
* subsystem is inactive, the other shows it available. That is
* the recorded failure, and this catches it at the transaction
* that made it true rather than re-detecting it on every call.
*
* WHY THE WRITE, NOT THE SERVING. A contradiction is BORN at two moments:
* when a fact is written, and when an artifact is composed. Checking at
* serving finds the same defect once per call, with no way to name which
* write caused it; checking the delta names the guilty write, costs one
* comparison against a single subject, and files ONE finding.
*
* WHAT THIS CANNOT DO, stated so nobody assumes otherwise: the check
* DETECTS, it never blocks the write. The engine's recorders cannot veto
* (hook throws are swallowed and the error path commits anyway), and
* blocking a park because tools were still registered would invert
* causality — the park is the correct fact; the stale serving is the
* defect. Dev posture throws AFTER the append, in the writer's own caller.
*/
import type { ContextError } from '../finding/types.js';
/** One map's engagement standing as the kernel just wrote it. */
export interface EngagementWrite {
readonly mapId: string;
readonly standing: 'engaged' | 'parked';
/** Iteration the write landed on — the epoch the comparison runs at. */
readonly iteration: number;
/** Tool names this map owns, as the mount declared them. */
readonly ownedToolNames: readonly string[];
}
/**
* Tool names actually on the wire for this call, and where that was read.
* Absent (rather than empty) when the caller could not see the wire — an
* unknown serving set never contradicts anything.
*/
export interface ServedTools {
readonly names: readonly string[];
readonly provenance: string;
}
/**
* Compare one engagement write against what is being served.
*
* Returns findings (usually none). A parked map whose owned tools have
* left the wire is the healthy case and returns nothing — which is a
* `checked-pass`, not silence: the caller files that disposition.
*/
export declare function invariantViolationsOf(write: EngagementWrite, served: ServedTools | undefined): readonly ContextError[];