UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

24 lines (23 loc) • 1.77 kB
import { type PeerDirectory, type PeerSessionRecord } from "../../agents/peer-directory.js"; import { type ContractAssertionRunner } from "./contract-harness.js"; /** The scope every case registers rows under; the scope-wall case constructs a second one. */ export declare const PEER_DIRECTORY_CONTRACT_SCOPE = "peer-kit-A"; export interface PeerDirectoryContractHooks { /** Write (or replace) one row through the host's own write protocol. The kit never writes a row * the engine's reader would refuse. */ write: (dir: PeerDirectory, record: PeerSessionRecord) => void | Promise<void>; runAssertion?: ContractAssertionRunner; } /** * The directory contract. Four readings, each the reason the engine can do something: * 1. **scope wall** — a listing is the ACCESSOR's scope only; the cross-principal wall's mechanical * seat is this filter, so a row leaking across scopes is a tenant leak, not a display bug; * 2. **the full set, copies** — live, dead AND deleted rows are all listed (a `name [ref]` is minted * over the full set; a dead row is the name truth offline delivery resolves through; a deleted * row resolves only to refuse), and a listed row is a COPY (mutating it changes no later listing); * 3. **resolution feeds on the listing** — the engine's own resolver, over the rows as listed, finds * a live row by name, still finds a dead one, and answers `deleted` for a tombstone; * 4. **restore is CAS-on-absent** (only where the host implements it) — an absent row is restored and * then listed; a present row is never overwritten (`false`, the existing row byte-unchanged). */ export declare function peerDirectoryContract(mk: () => PeerDirectory, hooks: PeerDirectoryContractHooks): Promise<void>;