UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

31 lines (30 loc) • 2.44 kB
/** * A session's write home, as {@link import("./engine.js").MemoryEngine.sessionMemoryStatus} reports it * (`SessionMemoryStatus.writeHome`): the canonical absolute directory of the write scope the session wrote under MOST * RECENTLY — `canonicalize(scopeDirFor(write scope))`, the derivation behind a leg's handle's `writableRoot`. Two sources * name a scope, each dated, and the NEWER one wins: * 1. the session's account row: every account-opening mount (a sessioned, unrestricted mount with a write face) records * its write scope there, dated by the account's (re-)open time — readable from any engine on the control plane; * 2. the entry carrying the session's newest committed lineage contribution, dated by that contribution — a session that * wrote without opening an account (provenance "off", a row written before the field) names its home this way, and so * does a leg that wrote AFTER an older account leg (an off-mode commit under another scope after a carry leg ended: * the older row must not hide the newer home). * 3. neither — ABSENT: a session that never opened an account and never committed. * A FAULTED source (a read that throws: an unreadable account ledger or lineage) answers absent and never falls through — * it may hide the newer scope, so the other source's word would be a stand-in. A SILENT source (the newest contribution's * entry is gone — deleted or a tombstone — or there is no account row) yields to the other source: a deleted note is an * ordinary state, not a fault, and the account row is the durable record of where the session writes. Older contributions * are never consulted. A registry that cannot derive a home (v1, an unfinished layout move) * answers absent before either source is read, so no read here goes through a face whose layout seat would finish the move * first and then name a post-move home. */ import type { MemoryEntry } from "./types.js"; export declare function sessionWriteHomeOf(input: { memoryDir: string; controlDir: string; sessionId: string; /** The caller's lineage read: entry id → this session's `lastAt` on it (undefined ⇔ that read faulted). */ contributions: ReadonlyMap<string, number> | undefined; /** A committed, side-effect-free entry read (the engine's audit face). */ readEntries: (ids: readonly string[]) => Promise<MemoryEntry[]>; }): Promise<string | undefined>;