@sema-agent/core
Version:
Stateless, task-oriented AI agent core
47 lines (46 loc) • 3.16 kB
TypeScript
import type { EntryCustodyReport } from "./file-backend.js";
import type { MemoryBackend } from "./types.js";
/**
* A store's answer for one id it does not hold:
* - `never` — its record is whole and names no deletion of the id in this scope: the id is new to it;
* - `deleted` — its record names a deletion of the id in this scope; `rev` is the version deleted last, when carried;
* - `undecidable` — its record cannot say (the chain is damaged, an event id is contradicted, a deletion omits scope,
* the store keeps no custody face, or the read failed); `why` says which. `why` is the engine's sentence: every word in it
* the store wrote (an event id, a damage reason, a read's thrown text) went through `foreignLine` where it was put in.
*/
export type DeletionRecord = {
readonly kind: "never";
} | {
readonly kind: "deleted";
readonly rev?: string;
} | {
readonly kind: "undecidable";
readonly why: string;
};
/** The precedence every reader of deletion evidence shares: a deletion the record names stands even when the rest of the
* record is impeached (a sound prefix proves it); otherwise an impeached record answers nothing; otherwise the id was
* never deleted. `deletedRev`: `undefined` = no deletion named, `null` = one named without its version. */
export declare function deletionRecordFrom(evidence: {
readonly deletedRev: string | null | undefined;
readonly sound: boolean;
readonly unsoundWhy?: string;
}): DeletionRecord;
/** The record one custody report (`custodyOf(id)`, the File store's or any backend's) gives for `id` in `scope`;
* `undefined` = the store has no custody face. A deletion event is a fact of its own scope (`scope` or legacy
* `from.scope`) and invisible from any other scope; one carrying no scope, or a contradicted `ev`, fails closed. */
export declare function deletionRecordOf(id: string, custody: EntryCustodyReport | undefined, scope: string): DeletionRecord;
/** The store's answer for an id a memory file carries in `scope` that no baseline of the mount names, given where the
* store holds it (`placement`): `held` when it holds it somewhere (the copy / rename lanes answer), otherwise its
* deletion record for `scope` — a placement that cannot be read answers `undecidable`, never `never`. */
export declare function unheldIdRecord(backend: MemoryBackend, id: string, scope: string, placement: {
readonly state: "absent" | "held" | "unknown";
}): Promise<DeletionRecord | {
readonly kind: "held";
}>;
/** The harvest's reason for not committing such a file: deleted ⇒ refused (the caller contains it); undecidable ⇒ deferred. */
export declare function unheldIdRefusal(record: Extract<DeletionRecord, {
kind: "deleted" | "undecidable";
}>): string;
/** Read the store's deletion record in `scope` for each id (its `custodyOf` face, one read per id). A store without the
* face, a throwing getter, or a read that throws answers `undecidable` for that id — never `never`. */
export declare function memoryDeletionRecords(backend: MemoryBackend, ids: Iterable<string>, scope: string): Promise<Map<string, DeletionRecord>>;