/**
 * ReplicatedPeerStreamReader — materializes a replicated store's per-origin records
 * from the coherence-journal streams on disk (WS2 send-side, the union-read half).
 *
 * Spec: docs/specs/WS2-SEND-SIDE-EMISSION-SPEC.md §3.3 + §3.4; the substrate is
 * docs/specs/multi-machine-replicated-store-foundation.md §7.1 (namespaced per-origin
 * storage), §7.2 (the union the reader merges).
 *
 * THE GAP THIS CLOSES: `ReplicatedStoreReader.loadOriginRecords` returned only the OWN
 * origin, so even a correctly-received peer record (durably written by
 * JournalSyncApplier to `peers/<M>.<kind>.jsonl`) was invisible to a read. This reader
 * is the seam that makes the union real: it reads the OWN stream
 * (`<self>.<kind>.jsonl` + archives) AND every peer replica stream
 * (`peers/<M>.<kind>.jsonl` + archives; quarantine + meta excluded), validates each
 * line through the SAME `validateReplicatedEnvelope` + store schema the writer used,
 * and folds to the LATEST record per `(origin, recordKey)` by HLC-max. A delete is a
 * tombstone (kept) so the union's delete-resolution + resurrection guard work.
 *
 * It supplies three seams to the rest of the system:
 *   - `loadOriginRecords(store, recordKey)` + `listRecordKeys(store)` — the
 *     ReplicatedStoreReader seams (the no-clobber union's per-origin input).
 *   - `loadWitness(store, recordKey)` — the emitter's `observed` source (the MAX HLC
 *     over every origin record held for the key — own prior + applied peers).
 *   - `loadOwnEntries(store, origin)` — the snapshot-serve seam (raw OWN entries by
 *     kind), replacing the `loadOwnEntries: () => ({})` stub.
 *
 * PURE-ish: all I/O is the injected `fsImpl` (defaults to node:fs); no Date, no
 * network. Bounded — replicated memory stores are small (per-kind retention caps), and
 * the read ceiling mirrors the applier's SERVE_READ_BYTE_CEILING.
 */
import { type JournalFs } from './CoherenceJournal.js';
import { type HlcTimestamp } from './HybridLogicalClock.js';
import { type ReplicatedKindRegistry } from './ReplicatedRecordEnvelope.js';
import type { OriginRecord } from './UnionReader.js';
import type { RawJournalEntry } from './StoreSnapshot.js';
export interface ReplicatedPeerStreamReaderConfig {
    /** Absolute path to the agent's `.instar/` directory (the stateDir). */
    stateDir: string;
    /** The replicated-kind registry — resolves store → kind + the store schema. */
    registry: ReplicatedKindRegistry;
    /** This machine's id (the OWN origin). */
    selfMachineId: string;
    /** Optional fs seam for fault-injection tests. Defaults to node:fs. */
    fsImpl?: JournalFs;
}
export declare class ReplicatedPeerStreamReader {
    private readonly stateDir;
    private readonly registry;
    private readonly selfMachineId;
    private readonly io;
    constructor(config: ReplicatedPeerStreamReaderConfig);
    /**
     * Every origin's CURRENT record for (store, recordKey) — the own stream + each peer
     * replica namespace, ONE record per origin (the latest by HLC, a delete kept as a
     * tombstone). The union reader merges these via the no-clobber rule. A single-machine
     * install returns only the own origin (so the union is a strict no-op = that record).
     */
    loadOriginRecords(store: string, recordKey: string): OriginRecord[];
    /** Every recordKey the store currently holds across ALL origins (for readAll). */
    listRecordKeys(store: string): string[];
    /**
     * The MAX HLC over every origin record this machine currently holds for
     * (store, recordKey) — own prior + applied peers. The author stamps this as the
     * record's `observed` witness. Returns undefined when none is held (first write of
     * the key) ⇒ the author omits `observed` ⇒ flag-on-conflict (the safe direction).
     * Sound: it only witnesses a version provably on disk, so a not-yet-pulled peer
     * version is absent here and the merge flags concurrent rather than silently
     * resolving (§7.2 err-toward-flag).
     */
    loadWitness(store: string, recordKey: string): HlcTimestamp | undefined;
    /**
     * The OWN-stream raw entries for `store`, keyed by contributing journal kind — the
     * single-origin snapshot input (§6). `origin` MUST be this machine (single-origin,
     * §6.1); a request for any other origin returns `{}` (we only serve what we
     * authored). Reads the own current + archive streams; returns ALL entries (the
     * materializer folds to the latest per recordKey and computes the seq watermark).
     */
    loadOwnEntries(store: string, origin: string): Record<string, RawJournalEntry[]>;
    /**
     * Build `recordKey → (origin → latest OriginRecord)` for a store by reading the own
     * stream + every peer replica stream and folding by HLC-max per (origin, recordKey).
     * Read FRESH each call (no cache) so a write-then-read is always consistent — the
     * stores are small + bounded, so the scan is cheap.
     */
    private materialize;
    /** Read + tolerant-parse every JournalEntry from the given stream files. */
    private readKindEntries;
    private journalDir;
    private peersDir;
    /** Own current + archive stream files for (origin, kind), newest-first by stamp. */
    private ownStreamFiles;
    /** Every peer replica current + archive stream file for `kind` (quarantine excluded). */
    private peerStreamFiles;
    /** Archive files `<safe>.<kind>.<stamp>.jsonl` in `dir`, newest-first. */
    private archivesFor;
}
//# sourceMappingURL=ReplicatedPeerStreamReader.d.ts.map