import type { CatchupPassDecisionReason, ConfiguredContextGraphMetadataReconciliationResult, DKGAgent, InspectedContextGraphReadinessV1, SwmSnapshotCoverage } from '@origintrail-official/dkg-agent'; import type { ContextGraphReadinessProvenance, DashboardDB } from '@origintrail-official/dkg-node-ui'; import type { CatchupJobResult } from './catchup-runner.js'; import { type ContextGraphIndependentPlaneEvidence, type ContextGraphReadinessPatch } from './context-graph-readiness-policy.js'; export { parseProjectSyncedReadinessPayload, type ProjectSyncedReadinessPayload } from './context-graph-project-synced-payload.js'; export { catchupPlaneCompletedWithoutFailure } from './catchup-proof.js'; export { CONTEXT_GRAPH_READINESS_VERSION, type ContextGraphReadinessPatch } from './context-graph-readiness-policy.js'; /** * The shared-memory shortfall clause appended to the incomplete-progress * terminal message. * * Every figure comes from ONE {@link SwmSnapshotCoverage} record — the counts, * the peer they are attributed to, and the sample — so the sentence can never * describe a graph state no peer reported, and the named Knowledge Assets * always belong to the manifest the counts came from. * * Returns `''` whenever there is nothing to add, which is what keeps the base * sentence byte-identical on every other path: no snapshot inventory was * observed, or the selected manifest was fully retrieved AND fully written — in * which case the shortfall lies on another plane, and reporting "0 outstanding" * beside an `unreachable` verdict would misdirect the reader. */ export declare function swmShortfallClause(coverage: SwmSnapshotCoverage | undefined, continuationPasses: number | undefined, stopReason?: CatchupPassDecisionReason): string; export type ContextGraphReadinessStore = Pick; export interface ContextGraphSubscriptionReadinessState { synced?: boolean; sharedMemorySynced?: boolean; metaSynced?: boolean; pendingMeta?: boolean; } export interface ContextGraphSubscriptionStatePatch { synced: boolean; sharedMemorySynced: boolean; /** Omitted when metadata could not be inspected; preserve existing facts. */ metaSynced?: boolean; pendingMeta?: boolean; } export interface MissingMetadataReadinessPatches { statePatch: ContextGraphSubscriptionStatePatch; readinessPatch: ContextGraphReadinessPatch; } /** Canonical fail-closed state for a graph without authoritative metadata. */ export declare function missingMetadataReadinessPatches(): MissingMetadataReadinessPatches; export declare function classifyExistingContextGraphReadiness(input: { subscription: ContextGraphSubscriptionReadinessState; readiness: ContextGraphReadinessProvenance; includeSharedMemory: boolean; hasConfirmedMeta: boolean; registration?: 'unregistered'; }): { alreadyReady: boolean; statePatch?: ContextGraphSubscriptionStatePatch; readinessPatch?: ContextGraphReadinessPatch; }; export declare function catchupResultHasCleanResponse(result: CatchupJobResult): boolean; export interface ContextGraphCatchupReadinessClassification { durablePlane: 'required' | 'not-applicable'; jobStatus: 'done' | 'failed' | 'denied' | 'partial' | 'unreachable'; error?: string; statePatch?: ContextGraphSubscriptionStatePatch; readinessPatch?: ContextGraphReadinessPatch; eventPayload?: { dataSynced: number; sharedMemorySynced: number; verifiedPrivateOnlyResponses: number; }; } /** * A subscription known only by its on-chain name hash cannot sync anything * under that id, whatever the peers answered: holders key the graph by its * cleartext id. Report exactly that (with the next step) instead of a generic * "retry" verdict. `identity` is the agent's note for the job's graph id; * anything other than a hash-only note returns null and the ordinary * classifier decides. */ export declare function classifyNameHashOnlyCatchup(identity: { readonly state: string; readonly message: string; } | null | undefined): { jobStatus: 'unreachable'; error: string; } | null; interface ContextGraphCatchupReadinessBaseInput { result: CatchupJobResult; includeSharedMemory: boolean; inspection: InspectedContextGraphReadinessV1; readinessBeforeCatchup: ContextGraphReadinessProvenance; independentPlaneEvidence?: ContextGraphIndependentPlaneEvidence; } /** * Canonical policy for converting one catch-up result into externally visible * subscription readiness. The HTTP route gathers live metadata and applies * the returned patches; all readiness decisions remain in this pure function. */ export declare function classifyContextGraphCatchupReadiness(input: ContextGraphCatchupReadinessBaseInput): ContextGraphCatchupReadinessClassification; export declare function readContextGraphReadiness(store: Partial, contextGraphId: string): ContextGraphReadinessProvenance; export declare function writeContextGraphReadiness(store: Partial, contextGraphId: string, readiness: Pick): void; export declare function withContextGraphReadinessMutationLock(agent: DKGAgent, contextGraphId: string, task: () => Promise): Promise; export type { ConfiguredContextGraphMetadataReconciliationResult }; /** * Repair, classify, and persist configured-graph readiness under one lock. * PROJECT_SYNCED persistence uses the same lock, so a newer authoritative * proof either wins before this operation classifies live state or runs after * its reset and restores readiness. */ export declare function reconcileConfiguredContextGraphMetadata(input: { agent: DKGAgent; store: Partial; contextGraphId: string; }): Promise; /** A wake-up requests verification; only its committed result is a sync event. */ export declare function persistCatalogReadiness(input: { agent: DKGAgent; store: Partial; contextGraphId: string; }): Promise; /** Persist ordinary sync completion only with data and confirmed metadata. */ export declare function persistProjectSyncedReadiness(input: { agent: DKGAgent; store: Partial; contextGraphId: string; dataSynced: number; sharedMemorySynced: number; verifiedPrivateOnlyResponses?: number; }): Promise; export declare function registerProjectSyncedReadinessPersistence(input: { agent: DKGAgent; store: Partial; log: (message: string) => void; }): void; /** * Deadline (ms) for confirming one legacy row during the readiness migration. * * The migration runs before the daemon API opens, and confirming a row can wait * on chain reads: a reverse name-hash scan for a row without an on-chain id, * and a finalized authority read queued on the agent's shared single-slot * authority coordinator. A row that misses the deadline fails closed exactly * like a row whose metadata could not be confirmed. */ export declare const CONTEXT_GRAPH_READINESS_MIGRATION_ROW_TIMEOUT_MS = 8000; /** * Wall-clock budget (ms) for every confirmation in one migration pass. Rows * still waiting when it is spent fail closed without any lookup, so the pass * stays bounded however many legacy rows a node holds. */ export declare const CONTEXT_GRAPH_READINESS_MIGRATION_BUDGET_MS = 30000; /** * One-time migration for subscription flags written before readiness carried * durable per-plane proof. Private/unconfirmed rows fail closed and must * complete a new catch-up. Confirmed public rows retain historical clean-empty * compatibility and receive provenance matching their already-persisted bits. * * The daemon awaits this before its API opens, so the pass is bounded: each * confirmation has a deadline, all of them share one budget, and a row that * misses either fails closed. Only rows this node actively holds are migrated. */ export declare function migrateLegacyContextGraphReadiness(input: { agent: DKGAgent; store: Partial; log: (message: string) => void; /** Per-row confirmation deadline; defaults to {@link CONTEXT_GRAPH_READINESS_MIGRATION_ROW_TIMEOUT_MS}. */ rowTimeoutMs?: number; /** Budget for the whole pass; defaults to {@link CONTEXT_GRAPH_READINESS_MIGRATION_BUDGET_MS}. */ budgetMs?: number; }): Promise; //# sourceMappingURL=context-graph-readiness.d.ts.map