import type { RuntimeEventBus } from '../events/index.js'; import { CacheRegistry, type MemoryCacheId, type RegisteredCache } from './cache-registry.js'; import { PauseController } from './pause-controller.js'; import { MemoryGovernor, type MemoryGovernorConfig, type MemoryGovernorDeps, type MemoryTripwireReceipt } from './memory-governor.js'; export interface MemoryGovernanceHandles { readonly cacheRegistry: CacheRegistry; readonly pauseController: PauseController; readonly memoryGovernor: MemoryGovernor; } export interface MemoryGovernanceWiringOptions { readonly config: MemoryGovernorConfig; /** The runtime bus the OPS_MEMORY_PRESSURE attention event is emitted onto. */ readonly runtimeBus?: RuntimeEventBus | undefined; /** Caches to register at construction (all KNOWN_MEMORY_CACHES for a full daemon). */ readonly caches: ReadonlyArray<{ readonly id: MemoryCacheId; readonly cache: RegisteredCache; }>; /** Deferrable background jobs the governor pauses under pressure. */ readonly jobIds: readonly string[]; /** Where the tripwire receipt is written so a supervisor sees the exit reason. */ readonly receiptPath?: string | undefined; /** * Graceful shutdown work run before a tripwire exit, the same session/store * snapshot + inhibitor-release path the daemon's signal handlers use. */ readonly onTripwireShutdown?: ((receipt: MemoryTripwireReceipt) => Promise | void) | undefined; /** Default true, the governor is a safety feature and starts ON. */ readonly start?: boolean | undefined; /** Test injection for the governor's I/O (sampler, clock, gc, exit). */ readonly deps?: Partial> | undefined; /** * A pre-built PauseController to reuse. The daemon composition builds this * EARLY so scheduler gates (isIdle/isEnabled/isBackgroundPaused) can consult * it before the governor exists; the jobs listed in `jobIds` are registered * onto it here (idempotent). */ readonly pauseController?: PauseController | undefined; /** A pre-built CacheRegistry to reuse; the `caches` are registered onto it. */ readonly cacheRegistry?: CacheRegistry | undefined; } /** Construct and (by default) start the memory governance layer. */ export declare function createMemoryGovernance(options: MemoryGovernanceWiringOptions): MemoryGovernanceHandles; /** The live collaborators the daemon composition hands the standard cache adapters. */ export interface DaemonMemoryGovernanceOptions { readonly config: MemoryGovernorConfig; readonly runtimeBus?: RuntimeEventBus | undefined; readonly cacheRegistry: CacheRegistry; readonly pauseController: PauseController; readonly jobIds: readonly string[]; readonly receiptPath: string; /** Graceful shutdown work run before a tripwire exit. */ readonly onTripwireShutdown?: ((receipt: MemoryTripwireReceipt) => Promise | void) | undefined; /** The daemon's knowledge stores (regular + agent + home-graph): real counts + a real jobRuns trim. */ readonly knowledgeStores: ReadonlyArray<{ retainedEntryCount(): number; pruneJobRuns(keep: number): number; }>; /** The shared session broker: real retained-record count + a real GC/truncate trim. */ readonly sessionBroker: { retainedRecordCount(): number; trimRetained(level: 'floor' | 'flush'): void; }; } /** * Build and start the daemon's memory governance with REAL cache adapters: * every registered cache exposes a genuine retained-entry count and a trim that * actually reclaims (knowledge job-run history pruning, session broker GC + * bucket truncation). Caches with no reachable real adapter are NOT registered *, a no-op registration would make the governor's shed tiers theater and the * tripwire's "flush didn't help" note vacuous. */ export declare function wireDaemonMemoryGovernance(options: DaemonMemoryGovernanceOptions): MemoryGovernanceHandles; //# sourceMappingURL=wiring.d.ts.map