/** * Bounded on-chain Context Graph discovery scheduling. * * ContextGraphStorage id enumeration runs first on every pass. It is the * authoritative history source: it lists every Context Graph that exists on * chain from a durable id cursor, with view calls only. The repair slot keeps * its mutable facts fresh at the repair cadence. * * The ContextGraphNameRegistry lanes run only while a registry is bound in the * Hub. The registry is archived and neither mainnet registers it, so there the * agent reports its absence once and both registry lanes are skipped instead * of scanning nothing every tick. Where it is bound, live discovery and * historical repair stay deliberately different lanes: live discovery resumes * its durable cursor with the chain adapter's reorg overlap and is the only * lane whose failure is retried as a pinned scheduler slot; historical repair * runs only after live success, owns an independent atomic cursor/target, and * is bounded on every invocation. */ /** Default completed-repair generation interval: about once per day. */ export declare const CHAIN_REPAIR_AUDIT_EVERY_TICKS = 48; /** @deprecated Use CHAIN_REPAIR_AUDIT_EVERY_TICKS. */ export declare const CHAIN_FULL_SCAN_EVERY = 48; export declare const CHAIN_DISCOVERY_SCAN_PAGE_BUDGET = 30; export declare const CHAIN_DISCOVERY_SCAN_INTERVAL_MS: number; export declare const MAX_CONSECUTIVE_SAME_SCAN_RETRIES = 3; /** * @deprecated No overdue unbounded resync is scheduled. Kept as a source-level * compatibility export for callers which imported the old policy constant. */ export declare const OVERDUE_FULL_RESYNC_RETRY_EVERY = 4; export type ScanOptions = { mode: 'incremental'; throwOnChainScanFailure: true; pageBudget: number; } | { mode: 'seedLiveTail'; throwOnChainScanFailure: true; pageBudget: number; }; type CancellableScanOptions = ScanOptions & { signal: AbortSignal; }; export interface ChainDiscoveryScanRunner { /** Run at most one live-then-repair pass; overlapping calls are dropped. */ run(): Promise; /** Arm the initial pass; the runner owns every later periodic deadline. */ schedule(initialDelayMs?: number): boolean; /** Clear the deadline, abort, and drain before agent/store teardown. */ close(): Promise; } export declare function chainDiscoveryScanOptions(input: { watermarkSeeded: boolean; pageBudget?: number; }): ScanOptions; export interface ScanSchedulerConfig { pageBudget?: number; /** Number of 30-minute ticks between completed historical repair generations. */ repairEveryTicks?: number; /** @deprecated Use repairEveryTicks. Compatibility is isolated at the runner boundary. */ fullScanEvery?: number; } export interface ScanSchedulerState { /** Advances only when a live scan settles its slot (success or retry exhaustion). */ readonly run: number; readonly pinned?: { readonly options: ScanOptions; readonly failures: number; }; } export declare const INITIAL_SCAN_SCHEDULER_STATE: ScanSchedulerState; export type ScanOutcome = { readonly ok: true; readonly found: number; } | { readonly ok: false; readonly error: unknown; }; export type ScanReport = { kind: 'discovered'; found: number; } | { kind: 'quiet'; } | { kind: 'retryScheduled'; run: number; mode: ScanOptions['mode']; failures: number; error: unknown; } | { kind: 'slotReleased'; run: number; mode: ScanOptions['mode']; attempts: number; error: unknown; }; export interface ScanPlan { readonly scan: ScanOptions; readonly priorFailures: number; readonly state: ScanSchedulerState; } export type ScanPlanStep = { readonly kind: 'ready'; readonly plan: ScanPlan; } | { readonly kind: 'needsWatermark'; readonly agedState: ScanSchedulerState; readonly complete: (watermarkSeeded: boolean) => ScanPlan; }; /** Pure live-lane planner. Failed scans retry with their exact captured mode. */ export declare function planScan(state: ScanSchedulerState, config?: ScanSchedulerConfig): ScanPlanStep; /** Pure live-lane transition. Retry exhaustion releases discovery liveness. */ export declare function commitScanOutcome(plan: ScanPlan, outcome: ScanOutcome): { state: ScanSchedulerState; report: ScanReport; }; /** * Single-flight I/O shell. The optional repair operation is separate so the * daemon can wrap only that call in the background RPC request class while * keeping live discovery in the foreground lane. */ export declare function createChainDiscoveryScanRunner(input: { agent: { hasContextGraphRegistryScanWatermark(): Promise; discoverContextGraphsFromChain(options: CancellableScanOptions): Promise; repairContextGraphRegistry?(options: { pageBudget: number; minimumIntervalMs: number; signal: AbortSignal; }): Promise; /** * Whether a ContextGraphNameRegistry is bound. When it resolves false the * registry lanes are skipped; agents without the probe keep them. */ hasContextGraphNameRegistry?(): Promise; /** ContextGraphStorage id enumeration from its durable cursor. */ discoverContextGraphsFromStorage?(options: { signal: AbortSignal; }): Promise; /** Refresh enumerated graphs' mutable facts, at most once per interval. */ refreshContextGraphsFromStorage?(options: { minimumIntervalMs: number; signal: AbortSignal; }): Promise; }; log: (msg: string) => void; pageBudget?: number; repairEveryTicks?: number; /** @deprecated Use repairEveryTicks. */ fullScanEvery?: number; /** Zero/omitted disables periodic rearming for manually driven callers. */ intervalMs?: number; }): ChainDiscoveryScanRunner; export {}; //# sourceMappingURL=chain-discovery-scan.d.ts.map