/** * The shutdown seam for a composed runtime graph. * * `createRuntimeServices()` starts pollers while it builds: the config-file * watch, the fleet registry tick, the memory governor, the watcher registry, * the cross-session orchestration sweep, the orchestration snapshot writer, the * push-subscription sweep, the knowledge scheduler, and the snapshot / * retention / consolidation schedulers. Every one of those owners already had * its own `stop()` or `dispose()`; what did not exist was anything that called * them. A host that built a graph could not take it back down, so * `DaemonServer.stop()` returned with two thirds of the daemon's timers still * ticking. * * Teardown is best-effort and total. One owner that throws must not strand the * owners behind it, mirroring the `Promise.allSettled` stance the daemon CLI * already takes on shutdown: a subsystem refusing to stop cannot be allowed to * leave the caller unable to shut anything down. * * Not every owner here holds a literal timer. The list is what the graph must * put down before it can honestly call itself stopped, which also covers the * agent runs it was hosting: an agent whose registry, engine and bus are gone * has nowhere to report to, and its in-flight provider call is only reachable * through its cancellation signal. */ /** Where a poller owner registers the call that stops it. */ export interface DisposalRegistry { /** * Register a teardown callback. * * @param label - Names the owner in the warning logged if teardown throws. * Use the thing being stopped ("fleet registry"), not the method. */ add(label: string, dispose: () => void): void; } /** A registry plus the one call that runs everything registered on it. */ export interface DisposalScope { readonly registry: DisposalRegistry; /** Run every registered teardown, newest first. Idempotent. */ dispose(): void; } export declare function createDisposalScope(scopeName: string): DisposalScope; /** * Every poller owner a composed runtime graph holds. * * Deliberately all-required and structurally typed. A poller added to the graph * later has to be named here to compile, which is what keeps this list honest, * the previous arrangement (each owner disposed at its own call site, or not) * is how seven of these came to be started and never stopped. Structural types * rather than the concrete classes so the consumer forks, which compose the * same subsystems from the published package, can call this too. */ export interface RuntimePollerOwners { /** Handle returned by `ConfigManager.watchConfigFiles()`. */ readonly stopConfigWatch: () => void; readonly watcherRegistry: { dispose(): void; }; readonly storeSnapshotScheduler: { stop(): void; }; readonly appendOnlyRetentionScheduler: { stop(): void; }; readonly memoryConsolidationScheduler: { stop(): void; }; readonly codeIndexReindexScheduler: { dispose(): void; }; readonly sessionOrchestration: { dispose(): void; }; readonly knowledgeService: { dispose(): void; }; readonly agentKnowledgeService: { dispose(): void; }; /** * Cancels the Home Graph post-sync self-improvement pump, a rescheduling * loop with a 5s start delay and a 5-15s sleep between as many as ten rounds. * It had a dispose() from the day it was written and simply was not named * here, which is the whole reason this list is all-required. */ readonly homeGraphService: { dispose(): void; }; readonly wrfcController: { dispose(): void; }; /** Disposing the engine also detaches the orchestration snapshot writer's hourly reap. */ readonly orchestrationEngine: { dispose(): void; }; readonly processRegistry: { dispose(): void; }; readonly memoryGovernor: { stop(): void; }; /** * Releases the ProjectIndex the orchestrator builds for each non-default * agent working directory (a worktree an agent was spawned into). Each holds * a debounced flush timer and is referenced only from the tool closures of a * cached registry, so nothing else can reach it. */ readonly agentOrchestrator: { dispose(): void; }; /** * Cancels the agent runs this graph was hosting, returning how many. Not a * poller, but the same kind of thing left ticking: an agent whose registry, * engine and bus have been disposed keeps its provider call in flight and * keeps sleeping out its retry backoff, with nothing left to report to. * See tools/agent/cancel-all.ts for the implementation both roots pass in. */ readonly cancelHostedAgentRuns: () => number; /** Absent in compositions that build no trigger family. */ readonly triggerManager?: { shutdown(): void; } | undefined; } /** * Register the stop call for every poller a runtime graph started. * * The push-subscription sweep is NOT here: it is constructed inside gateway * verb registration, which takes the registry directly and registers its own. */ export declare function registerRuntimePollers(registry: DisposalRegistry, owners: RuntimePollerOwners): void; //# sourceMappingURL=disposal.d.ts.map