import { type DKGAgent, type CatchupPassDecisionReason, type DurableProgressClassification, type DurableSyncDiagnostics, type DurableSyncResult, type SharedMemorySyncResult, type SwmSnapshotCoverage } from '@origintrail-official/dkg-agent'; import type { CatchupPhaseProgress, CatchupPlaneCompletionEvidence } from './catchup-proof.js'; export { addCatchupPlaneEvidence, catchupPeerPlaneEvidence, catchupPlaneCompletedWithoutFailure, catchupPlaneProvenByAuthorityHostedEmpty, catchupPlaneProvenByData, catchupPlaneProvenBySelectedScope, catchupPlaneProvenByUnanimousEmpty, catchupPlaneReady, } from './catchup-proof.js'; export type { CatchupPhaseProgress, CatchupPlaneCompletionEvidence, CatchupPlaneRoundDiagnostics } from './catchup-proof.js'; export interface CatchupJobResult { connectedPeers: number; totalPeers?: number; selectedPeers?: number; syncCapablePeers: number; peersTried: number; /** * Subset of `peersTried` whose per-peer sync round reached a responder * and did not collapse into a transport failure. A responder can still * time out part-way through, deny access, or serve metadata-only rows; this * counter exists so daemon status mapping can distinguish "curator offline" * from "reachable peer answered but did not complete cleanly". */ peersResponded: number; /** * Subset of `peersTried` whose per-peer sync round finished without a * transport failure, timeout, or explicit ACL denial, and with either real * progress or a clean non-metadata-only empty completion. */ peersSucceeded: number; /** * Sync-capable peers this run deliberately never contacted because an earlier * wave already proved every requested plane. These are neither failures nor * successes; they exist so status mapping and operators can tell an * early-stopped run from a run where peers were unreachable. */ peersNotAttempted?: number; /** Context Graph phases deferred by this node's local sync scheduler. */ deferredBackpressure: number; dataSynced: number; sharedMemorySynced: number; denied: boolean; deniedPeers: number; /** * Per-plane evidence produced before peer results are aggregated. Aggregate * diagnostics intentionally retain every timeout/denial for observability, * but readiness must not let one bad peer mask another peer that completed * the same plane cleanly and stored verified data. */ cleanPlaneCompletions?: { /** Always carries `verifiedPrivateOnlyPeers`; only the durable plane can produce it. */ durable: CatchupPlaneCompletionEvidence & { verifiedPrivateOnlyPeers: number; }; sharedMemory: CatchupPlaneCompletionEvidence; }; diagnostics?: { noProtocolPeers: number; durable: { fetchedMetaTriples: number; fetchedDataTriples: number; insertedMetaTriples: number; insertedDataTriples: number; bytesReceived: number; resumedPhases: number; timedOutPhases: number; completedPhases: number; checkpointAdvances: number; emptyResponses: number; metaOnlyResponses: number; /** Cryptographically verified V2 responses whose public graph is intentionally empty. */ verifiedPrivateOnlyResponses: number; dataRejectedMissingMeta: number; rejectedKcs: number; failedPeers: number; failedPhases: number; deferredBackpressure: number; deniedPhases?: number; /** A resolvable curator never cleanly answered this plane; see * `catchupPlaneProvenByUnanimousEmpty`. */ authorityUnanswered?: boolean; }; sharedMemory: { fetchedMetaTriples: number; fetchedDataTriples: number; insertedMetaTriples: number; insertedDataTriples: number; bytesReceived: number; resumedPhases: number; timedOutPhases: number; completedPhases: number; checkpointAdvances: number; emptyResponses: number; droppedDataTriples: number; failedPeers: number; failedPhases: number; deferredBackpressure: number; deniedPhases?: number; /** A resolvable curator never cleanly answered this plane; see * `catchupPlaneProvenByUnanimousEmpty`. */ authorityUnanswered?: boolean; /** * Public-SWM snapshot coverage for this graph, selected WHOLE from one * peer round by `selectSwmSnapshotCoverage`. The counts, the peer they * are attributed to and the missing sample are never mixed across peers. */ swmCoverage?: SwmSnapshotCoverage; /** Plane-neutral evidence that local admission yielded. */ localYield?: true; /** Snapshot phases left incomplete specifically by a local yield; zero on clean results. */ snapshotPlaneIncomplete: number; /** Extra passes over the peer set beyond the first. */ continuationPasses: number; /** * Why the bounded repeat stopped, as the policy's own closed union — so a * new reason cannot reach the terminal message unnoticed. */ continuationStopReason?: CatchupPassDecisionReason; /** * `bytesReceived` split into its replay half (metadata + aggregate data, * which every pass re-fetches in full) and its useful half (snapshot * content), so the cost of repeating the walk stays measurable instead of * being merged into one scalar. The two sum to `bytesReceived`. */ replayPhaseBytesReceived: number; snapshotPhaseBytesReceived: number; }; }; } export interface CatchupRunRequest { contextGraphId: string; includeSharedMemory: boolean; /** Host agent owns one durable transfer across every peer-shaped Worker round. */ graphOwnedDurableRecovery?: boolean; } /** * Why the host bridge did not run a requested catch-up plane. * * - `catalog-authoritative`: legacy durable sync drops a catalog-authoritative * graph before sending any request (`syncFromPeerDetailed`). * - `selected-lane-refused`: no accepted RFC-64 public policy was active for the * graph when this call started, or the recovery lease revoked the lane. */ export type CatchupPlaneNotAttemptedReason = 'catalog-authoritative' | 'selected-lane-refused'; /** * A plane the host declined to run. Neither reason is an answer from the peer, * so the worker records the plane as not attempted: never as a response and * never as a transport failure. */ export interface CatchupPlaneNotAttempted { readonly kind: 'catchup-plane-not-attempted'; readonly reason: CatchupPlaneNotAttemptedReason; } /** The host explicitly switched a selected request to the agent's legacy SWM lane. */ export interface CatchupLegacySharedMemoryFallback { readonly kind: 'legacy-shared-memory-fallback'; readonly shared: SharedMemorySyncResult; } export declare function isCatchupPlaneNotAttempted(value: unknown): value is CatchupPlaneNotAttempted; export type DurableLegDiagnostics = DurableSyncDiagnostics & Pick; export interface DurableLegSummary { insertedTriples: number; diagnostics: DurableLegDiagnostics; complete: boolean; state: DurableCatchupLegState; failureReasons: DurableCatchupFailureReason[]; } export type DurableCatchupLegState = 'complete' | 'incomplete-progress' | 'failed' | 'indeterminate' | 'legacy'; export type DurableCatchupFailureCode = 'failedPeers' | 'failedPhases' | 'deniedPhases' | 'rejectedKcs' | 'dataRejectedMissingMeta' | 'incompleteWithoutProgress' | 'indeterminateSettlement'; export type DurableCatchupFailureReason = { code: DurableCatchupFailureCode; count: number; } | { code: 'exception'; message: string; }; /** The only agent capabilities required by the route-level durable leg. */ export interface DurableCatchupAgent { syncFromPeerDetailed?: OmitThisParameter; syncFromPeer?: OmitThisParameter; } export interface DurableCatchupLegResult { insertedTriples: number; state: DurableCatchupLegState; complete?: boolean; diagnostics?: DurableLegDiagnostics; failureReasons?: DurableCatchupFailureReason[]; } export interface DurableCatchupAttempt { durableState?: DurableCatchupLegState; durableComplete?: boolean; durableError?: string; error?: string; } export interface DurableCatchupRequestOutcome { attempts: DurableCatchupAttempt[]; perContextGraphCompletion: Array; complete?: boolean; allPeersFailed: boolean; noEligibleAttempts: boolean; incomplete: boolean; responseStatus: 200 | 503; errorBody: { errorCode: 'DURABLE_CATCHUP_ALL_PEERS_FAILED' | 'DURABLE_CATCHUP_NO_ELIGIBLE_PEERS' | 'DURABLE_CATCHUP_INCOMPLETE'; error: string; retryable: true; } | undefined; } /** * Adapt the agent's typed durable result for operator-facing catch-up APIs. * Whole-leg completion comes only from the explicit agent contract; phase * counters remain diagnostics and can describe safely committed prefixes. */ export declare function summarizeDurableLeg(result: DurableSyncResult): DurableLegSummary; /** Convert typed leg failures to the legacy operator-facing message at the HTTP boundary. */ export declare function formatDurableCatchupFailure(reasons: readonly DurableCatchupFailureReason[] | undefined): string | undefined; /** * Execute one durable route leg behind a typed capability boundary. Detailed * agents expose completion/diagnostics; older agents retain the legacy count. */ export declare function runDurableCatchupLeg(agent: DurableCatchupAgent, peerId: string, contextGraphId: string, overallTimeoutMs: number): Promise; export declare function durableCatchupCompletionFor(attempts: readonly DurableCatchupAttempt[]): boolean | undefined; /** * Aggregate completion across every requested CG. A complete subset must not * manufacture a complete whole-request verdict when another CG had no result. */ export declare function classifyDurableCatchupRequest(perContextGraphAttempts: ReadonlyArray, includeDurable: boolean, includeSharedMemory: boolean): DurableCatchupRequestOutcome; export declare function catchupPeerSucceeded(durable: CatchupPhaseProgress | null | undefined, shared: CatchupPhaseProgress | null | undefined, peerDenied: boolean, durableComplete?: boolean, sharedCompletion?: { progress: DurableProgressClassification; /** This lane requires an explicit terminal boundary, not just clean I/O. */ terminalBoundaryRequired: boolean; }): boolean; export declare function catchupPeerResponded(durable: CatchupPhaseProgress | null | undefined, shared: CatchupPhaseProgress | null | undefined): boolean; export interface CatchupRunner { run(request: CatchupRunRequest): Promise; close(): Promise; } export declare function createCatchupRunner(agent: DKGAgent): CatchupRunner; export declare function createInlineCatchupRunner(agent: DKGAgent): CatchupRunner; //# sourceMappingURL=catchup-runner.d.ts.map