agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
56 lines (55 loc) • 3.13 kB
TypeScript
/**
* Store capabilities — the two declared facts a store may state about its own
* `search()`, and the refusals they buy.
*
* Pattern: guard clauses over declared port capabilities.
* Role: memory/store layer, next to the port whose bits they read.
* Emits: N/A.
*
* ── The failure this exists to end ──────────────────────────────────────────
* `MemoryStore.search` is optional, so "can this store rank vectors?" was
* answered by `if (store.search)` everywhere — a check that asks whether the
* METHOD exists. Some stores implement `search()` and rank on their own side
* over a population they derived themselves: `AgentCoreStore.search()` takes
* the query as TEXT and returns the memory records AgentCore's extraction
* strategies built, not the entries this library wrote. Handed one of those,
* `indexCorpus` type-checks, runs, embeds the whole corpus, pays for it, and
* reports `embedded: 214` — and not one of those 214 chunks can ever come
* back. The index is real. The retrieval is empty. Nothing anywhere says so.
*
* A method's presence cannot express that, so the port grew one declared bit
* ({@link MemoryStore.supportsVectorSearch}) and this is the one place that
* reads it. **Absence is not a `false`**: a store that declares nothing is
* treated exactly as it was before this existed, which is what keeps every
* third-party adapter working unchanged.
*/
import type { MemoryStore } from './types.js';
/**
* The ranking mode a store DECLARES, with a contradiction refused by name.
*
* Two members answer two questions ({@link MemoryStore.supportsVectorSearch}
* "can you serve my vectors back?" and {@link MemoryStore.ranksBy} "what query
* form does your search take?"), and a store may state either, both, or
* neither. Both, disagreeing, is the one case that cannot be resolved: there is
* no reading of `{ supportsVectorSearch: true, ranksBy: 'server-text' }` that
* is not somebody's bug, and picking a winner would encode a guess about which
* line was the mistake. Refused — the same law that refuses `topK` beside
* `retrieval`.
*
* @returns `'vector'` | `'server-text'` | `undefined` (undeclared — the state
* every adapter written before 9.3.0 is in, and the one that must
* change nothing).
* @throws when the two declarations contradict each other.
*/
export declare function resolveRankingMode(store: MemoryStore, caller: string): 'vector' | 'server-text' | undefined;
/**
* Refuse a store that has declared it cannot rank the vectors it is given.
*
* @param store the store the caller passed.
* @param caller the function name to put in the message — the call the
* reader actually wrote, not this helper.
* @throws when `store.supportsVectorSearch === false`, when it declares
* `ranksBy: 'server-text'`, or when the two declarations contradict.
* Never throws on a store that declares nothing.
*/
export declare function assertServesVectors(store: MemoryStore, caller: string): void;