@sema-agent/core
Version:
Stateless, task-oriented AI agent core
35 lines (34 loc) • 2.51 kB
TypeScript
import type { MemoryBackend } from "./types.js";
export interface MemoryBackendContractHooks {
make: () => Promise<MemoryBackend> | MemoryBackend;
/** A second backend instance over the SAME storage as the given one (cross-instance CAS cases). */
makeSibling?: (of: MemoryBackend) => Promise<MemoryBackend> | MemoryBackend;
/**
* design/142 §6.3: the ONLY way to run the suite without `makeSibling`. State WHY this store has no
* shared-storage second instance (e.g. "process-exclusive single-writer file store; cross-process CAS
* covered by <suite>"). Runs as a named, visible case (a LOUD skip) — never a silent 16/17 pass.
* Authoritative-backend certification (§6.1 (a)) must provide `makeSibling` instead.
*/
skipCrossInstanceCas?: string;
/** Wrap each case (vitest `it`, sequential SQL chaining, …). Default: run sequentially. */
runAssertion?: (name: string, fn: () => Promise<void>) => void | Promise<void>;
/**
* design/178 v2-a §1.3 — the OPTIONAL audit-face clauses' report seat (#196
* `onOptionalMember` posture: absence is REPORTED, never a silent green — a run without this
* hook still passes on an absent face, but a certifying harness that wires it can tell
* "verified" from "the store never offered the face"). The three faces are capability probes on
* the concrete class (`committedSnapshotOf` / `committedSnapshotsOfScopes` / `custodyOf`); the
* `MemoryBackend` interface itself is untouched, so absence is legal — the engine's provenance
* assembly answers it as capability-absent.
*/
onOptionalMember?: (report: {
member: "committedSnapshotOf" | "committedSnapshotsOfScopes" | "custodyOf" | "eraseWithEvidence" | "exportSnapshotOf" | "governanceExport" | "custodyImport" | "importBundleCommit";
status: "verified" | "absent";
}) => void;
}
/** Run the full conformance suite. Throws (assert) on the first violated contract clause. */
export declare function memoryBackendContract(hooks: MemoryBackendContractHooks): Promise<void>;
/** Cross-backend value equivalence: same fixture ⇒ IDENTICAL (id, slug, score) search projections on
* two backends (File vs Pg lexical floor must not drift — assertMemoryValueEquivalence precedent).
* mtimeMs/sizeBytes are backend-native (fs stat vs column) and deliberately not compared. */
export declare function assertMemoryBackendSearchEquivalence(a: MemoryBackend, b: MemoryBackend): Promise<void>;