import { type ControllerLog, type KeyState, type SignedEvent } from '@kokuin/controller'; import type { StoreProvider } from '@kubun/db'; import { type Logger } from '@kubun/logger'; import type { EngineEvents } from './engine-events.js'; import type { EngineEventBus } from './events.js'; export type ControllerHeadState = { status: 'ok'; state: KeyState; log: ControllerLog; digest: string; } | { status: 'missing'; }; /** A version changes whenever the accepted head moves. */ export declare function controllerHeadVersion(head: ControllerHeadState): string; export type IngestOutcome = 'unchanged' | 'advanced' | 'rejected'; export type IngestSource = 'network' | 'handoff' | 'service' | 'local'; export type ControllerHeadHistory = { log: ControllerLog | null; }; export type ControllerHeadParams = { eventBus: EngineEventBus; logger?: Logger; }; /** External evidence must commit independently of a caller's mutation. */ export declare class ControllerHeadTransactionError extends Error { constructor(source: IngestSource); } export declare class ControllerHeadLockError extends Error { constructor(); } /** Event-wise digest prefix, equal logs included. False for unhashable evidence. */ export declare function isLogPrefixOf(prefix: Array, log: Array): boolean; /** Owns controller-log arbitration and answers from the accepted stored log. */ export declare class ControllerHead { #private; constructor(params: ControllerHeadParams); assertStoreSchema(stores: StoreProvider): Promise; head(stores: StoreProvider, did: string): Promise; headForUpdate(stores: StoreProvider, did: string): Promise; history(stores: StoreProvider, did: string): Promise; ingest(stores: StoreProvider, did: string, candidates: Array>, source: IngestSource): Promise; }