import type { EventV3 } from "./contract.js"; import { type EventV3RecoveryFailure, type EventV3RecoveryReceipt } from "./recovery-record.js"; export type LedgerDiagnosticCodeV3 = "malformed_json" | "partial_final_frame" | "unsupported_major" | "invalid_contract" | "unsupported_schema_digest" | "unexpected_schema_digest" | "noncanonical_frame" | "conflicting_event_id" | "causal_parent_missing" | "wall_clock_regression_unmarked" | "monotonic_clock_regression" | "producer_sequence_gap" | "unresolved_attestation" | "missing_genesis" | "multiple_genesis" | "genesis_not_first" | "genesis_digest_mismatch" | "missing_activation" | "activation_genesis_mismatch" | "advance_prior_mismatch" | "advance_reader_incompatible" | "advance_digest_unsupported" | "advance_boundary_invalid" | "advance_boundary_missed" | "cursor_genesis_mismatch" | "cursor_position_missing" | "catalog_invalid" | "missing_segment" | "segment_digest_mismatch" | "manifest_digest_mismatch" | "manifest_segment_mismatch" | "active_replaced" | "recovery_record_invalid"; export interface LedgerDiagnosticV3 { code: LedgerDiagnosticCodeV3; byte_offset: number; segment_ordinal: number; event_id?: string; } export interface LedgerFrameV3 { raw: string; position: { segment_ordinal: number; byte_offset: number; }; } export interface PositionedEventV3 { event: EventV3; position: LedgerFrameV3["position"]; } export interface SchemaAdvanceV3 { event_id: string; prior_schema_digest: string; next_schema_digest: string; effective_position: LedgerFrameV3["position"]; } export interface ReadLedgerV3Options { authority?: "candidate" | "active"; reader_build?: string; accepted_schema_digests?: readonly string[]; } export interface ReadLedgerV3Result { events: PositionedEventV3[]; diagnostics: LedgerDiagnosticV3[]; complete: boolean; genesis_id?: string; active_schema_digest?: string; advances: SchemaAdvanceV3[]; bytes: number; failed_epochs?: EventV3RecoveryReceipt[]; } export interface LedgerCursorV3 { genesis_id: string; segment_ordinal: number; byte_offset: number; event_id: string; } export interface ReadLedgerV3SinceResult extends ReadLedgerV3Result { cursor?: LedgerCursorV3; reset_required: boolean; } /** Inspect one failed active authority without weakening the canonical read boundary. */ export declare function inspectInvalidActiveAuthorityV3(coordRoot: string, controlReason: string): EventV3RecoveryFailure; /** Hash one preserved V3 authority by relative path, byte count, and file digest. */ export declare function digestEventV3AuthorityDirectoryV3(root: string): `sha256:${string}`; export interface PendingAdvance { event_id: string; next_schema_digest: string; position: LedgerFrameV3["position"]; } export interface EventV3AuthorityStorageVersionV3 { fingerprint: `sha256:${string}`; stable_fingerprint: `sha256:${string}`; active_bytes: number; } export interface EventV3AppendValidationCheckpointV3 { format: "harnery-event-v3-append-validation-checkpoint"; format_version: 1; reader_build: string; accepted_schema_digests: string[]; seen_event_ids: string[]; producer_sequences: Array<[string, number]>; attestation_ids: string[]; clocks: Array<[string, number, string?]>; event_count: number; genesis_id?: string; active_schema_digest?: string; pending?: PendingAdvance; active_segment_ordinal: number; validated_active_bytes: number; } export declare const EVENT_V3_LEDGER_RELATIVE_ROOT: ".harnery/ledgers/v3"; export declare const EVENT_V3_CONTROL_WITNESS_RELATIVE_PATH: ".harnery/ledgers/v3/control-state-witness.json"; export declare const EVENT_V3_CONTROL_CHECKPOINT_RELATIVE_PATH: ".harnery/ledgers/v3/control-state-validation.json"; export declare function eventV3Paths(coordRoot: string): { root: string; active: string; catalog: string; segments: string; }; /** Stable file target for change notification only; reads still go through readLedgerV3. */ export declare function eventV3ActiveWatchPath(coordRoot: string): string; /** Stable auxiliary control-cache target; canonical event reads remain inside this module. */ export declare function eventV3ControlWitnessPathV3(coordRoot: string): string; /** Stable auxiliary validator-checkpoint target owned by the control witness. */ export declare function eventV3ControlCheckpointPathV3(coordRoot: string): string; /** * Content-independent identity for the complete filesystem authority. * * The control witness authenticates this value after a complete validation. * Any append, rewrite, inode replacement, catalog change, sealed-segment * change, or recovery-record change produces a different fingerprint and * sends the control reader back through the canonical full validation path. */ export declare function eventV3AuthorityStorageVersionV3(coordRoot: string): EventV3AuthorityStorageVersionV3; /** Serialize the validator tail produced by the current complete cached read. */ export declare function readEventV3AppendValidationCheckpointV3(coordRoot: string): EventV3AppendValidationCheckpointV3 | undefined; /** * Validate only the bytes appended after an authenticated checkpoint. * Unsupported or semantically invalid transitions return undefined so the * control reader falls back to a complete canonical validation. */ export declare function advanceEventV3AppendValidationCheckpointV3(coordRoot: string, checkpoint: EventV3AppendValidationCheckpointV3): EventV3AppendValidationCheckpointV3 | undefined; /** Parse an untrusted persisted checkpoint without weakening the writer fence. */ export declare function parseEventV3AppendValidationCheckpointV3(value: unknown): EventV3AppendValidationCheckpointV3 | undefined; /** Read the complete V3 ledger through catalog-bound filesystem discovery. */ export declare function readLedgerV3(coordRoot: string, options?: ReadLedgerV3Options): ReadLedgerV3Result; export declare function readLedgerV3Since(coordRoot: string, cursor?: LedgerCursorV3, options?: ReadLedgerV3Options): ReadLedgerV3SinceResult; /** * Validate an already-discovered V3 event stream in exact physical order. * Filesystem/catalog discovery feeds this boundary; every downstream reader * and projection consumes its positioned, authority-checked result. */ export declare function readLedgerFramesV3(frames: readonly LedgerFrameV3[], options?: ReadLedgerV3Options): ReadLedgerV3Result; export declare function readLedgerFramesV3Since(frames: readonly LedgerFrameV3[], cursor?: LedgerCursorV3, options?: ReadLedgerV3Options): ReadLedgerV3SinceResult; //# sourceMappingURL=reader.d.ts.map