import { INLINE_PAYLOAD_MAX_BYTES, PayloadRefSchema } from './schema.js';
import type { WorkflowEvent } from './schema.js';
/**
 * What the runtime supplies to `append`.  The append path fills in
 * `eventId` and `schemaVersion`.  Callers must supply `runId`, `type`,
 * `actor`, `payload`, and may optionally pass `timestamp` (defaults to
 * Date.now()) and/or `payloadHash` (only when payload is a ref — see
 * events doc §1.1).
 *
 * The discriminated union over WorkflowEvent distributes through Omit, so
 * each event type's payload shape is preserved at the call site.
 */
export type EventDraft = Omit<WorkflowEvent, 'eventId' | 'schemaVersion' | 'timestamp'> & {
    timestamp?: number;
};
export declare class EventLog {
    readonly runId: string;
    readonly runDir: string;
    readonly eventsFile: string;
    readonly blobDir: string;
    private seq;
    private seqLoaded;
    private cachedMtimeMs;
    private cachedSize;
    constructor(runId: string, baseDir: string);
    /**
     * Append one event.  Atomic across:
     *   1. all EventLog instances for the same runId in this process
     *      (module-level mutex map), and
     *   2. other OS processes touching the same events file
     *      (`withFileLock` over `events.ndjson.lock`).
     *
     * Codex round 4 finding 1: payload envelope MUST be inline.  Large
     * business data goes through `OutputRef`-shaped fields (e.g.
     * `runCreated.inputRef`, `activitySucceeded.outputRef`); the caller is
     * responsible for writing the blob and passing a fully-formed
     * `OutputRef` inline.  The append path no longer auto-spills payloads —
     * doing so silently broke replay for any ref-payload event because the
     * existing replay projection unconditionally skipped the ref branch.
     *
     * Payload-ref payloads (`{ ref, bytes, schemaVersion }`) are still
     * supported for callers who genuinely need to ref-out the envelope
     * payload (e.g. a custom dashboard projection), but the caller must
     * supply both the blob and `payloadHash` upfront; this path is not
     * exercised by the v0 runtime.
     */
    append(draft: EventDraft): Promise<WorkflowEvent>;
    private appendLocked;
    /**
     * Read all events in append order.  Used by replay (events doc §5.2)
     * and seq recovery on restart.  Returns [] if the log doesn't exist
     * yet.
     *
     * Throws if any line fails schema validation — events doc treats the
     * log as authoritative and corruption should fail loud, not silently
     * skip lines.
     */
    readAll(): Promise<WorkflowEvent[]>;
    /**
     * Read the blob referenced by a ref-payload event.  Used when a caller
     * elected to spill their own OutputRef payload to disk; not used by
     * envelope-payload paths since v0.1.2 round-4 disallows envelope spill.
     */
    readBlob(ref: string): Promise<Buffer>;
    /** Current seq counter — exposed for tests / dashboard. */
    currentSeq(): Promise<number>;
    /**
     * Refresh `this.seq` if the events file has changed since we last loaded.
     * Stat is cheap; full re-scan only fires when the cached mtime/size differ
     * from disk — protects against another process having appended since our
     * last write.
     */
    private refreshSeqIfStale;
}
export { PayloadRefSchema, INLINE_PAYLOAD_MAX_BYTES };
export type { WorkflowEvent };
//# sourceMappingURL=append.d.ts.map