UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

60 lines (59 loc) • 4.42 kB
import { type MemoryBackend, type MemoryControlObjectKind, type MemoryGovernanceDocName, type MemoryGovernanceStore } 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" | "judgesErasureScopes" | "judgesPatchScopes" | "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>; export interface MemoryGovernanceStoreContractHooks { /** A FRESH, EMPTY store per case. */ make: () => Promise<MemoryGovernanceStore> | MemoryGovernanceStore; /** Leave `store`'s record of `record` malformed in its own storage (bytes that are not the record's shape — for a * governance document, bytes that do not parse): the fail-closed cases read it back and must be refused, never read * as an empty record. For a control object, leave `{ object, name }` standing but unreadable (the File store: a * directory or a link to nothing in its place), and `{ listing }` a kind whose names cannot be enumerated (the File * store: a file where the kind's directory is). */ corrupt: (store: MemoryGovernanceStore, record: "gate" | "intents" | "run" | MemoryGovernanceDocName | { readonly object: MemoryControlObjectKind; readonly name: string; } | { readonly listing: MemoryControlObjectKind; }) => Promise<void> | void; /** Wrap each case (vitest `it`, …). Default: run sequentially. */ runAssertion?: (name: string, fn: () => Promise<void>) => void | Promise<void>; } /** * The consolidation store conformance suite (`MemoryBackend.governance`): what an engine relies on when it keeps its * consolidation state in a store — a missing record reads empty and a malformed one is refused, a transaction's reads * and writes are not interleaved by another's (the plan owner fence and the seat CAS), the run claim's newer writer * wins and the older one stops, and a mint archive can be written, read and erased. Runner-agnostic (node:assert); * throws on the first violated clause. */ export declare function memoryGovernanceStoreContract(hooks: MemoryGovernanceStoreContractHooks): 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>;