UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

29 lines (28 loc) • 2.26 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. Five 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); * 5. **every listed row is one the engine's reader accepts** — the engine reads a listing through * `readPeerSessionRecord` and one refused row faults the WHOLE listing (dropping it would resize refs and * change resolution over the full set), so a row that does not say `where`, or a non-local row carrying a * machine-bound member, takes the directory's peer lane down. (How a host decides `where` is its own; * the kit does not require the written value back.) */ export declare function peerDirectoryContract(mk: () => PeerDirectory, hooks: PeerDirectoryContractHooks): Promise<void>;