UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

50 lines (49 loc) • 4.29 kB
import { type MemoryErasureAttestation } from "./file-backend.js"; /** One frozen copy: the raw index text each mounted plane's injection was composed from, and whether a marked * (external-origin) entry stood in any of them. */ export interface IndexCopy { readonly planes: Readonly<Partial<Record<"project" | "personal", string>>>; readonly marked: boolean; } /** The most the process keeps, in bytes over every copy — its index text in UTF-8, its name, its stores, and a fixed charge * per copy ({@link INDEX_COPY_OVERHEAD_BYTES}, so that many empty copies are bounded too); the oldest copies go first. */ export declare const INDEX_COPIES_MAX_BYTES: number; /** What each copy is charged beyond its text, name and stores. */ export declare const INDEX_COPY_OVERHEAD_BYTES = 256; /** The digest a copy is named by (sha256 over its planes, by plane name, and its marked bit). */ export declare function indexCopyDigest(copy: IndexCopy): string; /** A mounted plane a copy is read through: its memory directory and the store state its mount read * ({@link readAdmittedStoreState}). */ export interface IndexCopyPlane { readonly memoryDir: string; readonly storeState?: unknown; } /** Keep `copy` as frozen under `key`, read through `planes`; answers its digest. Not kept: a copy over the whole bound, and * one a plane of which was read under a store state this process did not admit, or admitted before the store's copies were * last dropped (a mount in flight across an erasure or a lower count: what it listed may be what was erased). */ export declare function keepIndexCopy(key: string, copy: IndexCopy, planes: readonly IndexCopyPlane[]): string; /** The copy frozen under `key` whose bytes are `digest`, or undefined. */ export declare function indexCopyOf(key: string, digest: string): IndexCopy | undefined; /** Drop every copy any of whose planes was read from `store` (a memory directory, as its handle names it); a mount of the * store whose state was read before this keeps nothing ({@link keepIndexCopy}). */ export declare function dropIndexCopiesOf(store: string): void; /** A mount's store state, read by `read`, under the rule that a store's erasure count only goes up. Admitted when its count is * no lower than the highest one this process has read of `store` when the read lands; a copy may then be kept under it until * the store's copies are next dropped after the read began. A lower count is not admitted, and every copy this process froze * of the store is dropped at once, since one frozen under a count the store reads again would be found by its key past the * erasure that moved the count. Why it is lower is answered, because the two causes ask different things of an operator: * `"lowered"` — lower than the highest count this process had read when THIS read began: the store's count went down, which * only a removed or rolled-back account does (until the store reads that count again, or the process restarts, nothing of it is * frozen here); `"overtaken"` — no lower than that, but a read that began later landed a higher count first: this read is * stale, and the next one reads the store again. */ export declare function readAdmittedStoreState<S extends { readonly erasures: number; }>(store: string, read: () => Promise<S>): Promise<S | "lowered" | "overtaken">; /** An erasure's `indexLine` class also answers for these copies: one in another process is found by a key that holds the * store's erasure count, so a call whose count did not move (`counted` false: the engine's clearance step over the ids it * resolved did not run to its answer) may leave one standing — the class is then `unverified` and the request `partial`, * whether or not this call deleted anything itself (a repeat of a request whose own count did not land deletes nothing, * and the count is still where that request left it). `undefined`: a face's attestation that cannot be read or copied * cannot carry the answer — the caller hands it on as it came and discloses that instead (no throw over a committed * erasure, never silent: the sweep's rule for the same answer). */ export declare function indexCopiesAnswered(att: MemoryErasureAttestation, counted: boolean): MemoryErasureAttestation | undefined;