import type { RuntimeDirectoryEntry } from "./directory-store.js"; import type { ListedRuntimeObject, RuntimeAddress, SerializedRuntimeAddress } from "./messaging-contract.js"; export interface DirectoryResolutionContext { /** Who is asking. Scopes "a stable child id beats a name" to the asker's own children. */ from: RuntimeAddress; } export type DirectoryResolution = { kind: "resolved"; entry: RuntimeDirectoryEntry; } | { kind: "ambiguous"; candidates: ListedRuntimeObject[]; } | { kind: "stale-name"; reason: string; candidates: ListedRuntimeObject[]; } | { kind: "not-found"; reason: string; }; /** WS-15 §6.4's seven-step restart recovery, reported step by step. */ export interface RuntimeDirectoryRecoveryStep { step: 1 | 2 | 3 | 4 | 5 | 6 | 7; name: string; outcome: string; } export interface RuntimeDirectoryRecovery { steps: RuntimeDirectoryRecoveryStep[]; entriesLoaded: number; /** Entries whose runtime object no longer exists and were marked accordingly (never deleted silently). */ staleMarked: number; cursorsRestored: number; heldMessagesFound: number; } /** WS-15 §6.1. Lane B implements; the spine pins the signature. */ export interface RuntimeDirectory { list(scope?: { parent?: SerializedRuntimeAddress; }): Promise; get(address: SerializedRuntimeAddress): Promise; record(entry: RuntimeDirectoryEntry): Promise; forget(address: SerializedRuntimeAddress): Promise; /** `to` is the raw model- or user-supplied target string (WS-10 §10.1 caps it at 300 chars, no newline, no `*`). */ resolve(to: string, context: DirectoryResolutionContext): Promise; recover(): Promise; }