/** * v3 journal — append-only event stream (the run's audit truth). * * Codex's v1-review blocker #1: v3 is NOT a "only-mutable-STATE" recoverable * system. `journal.ndjson` is the append-only source of audit truth (one JSON * object per line, `ts`-stamped) from which `state.ts` materializes the STATE * checkpoint. Concurrency / retry / gate / cancel / failure-root-cause all * leave an ordered trail here. * * Append-only + line-oriented is crash-tolerant only when the next writer * repairs an interrupted FINAL line first. Read-only projections may ignore * that tail, but appending after it would concatenate two JSON objects and * permanently corrupt the history. Every mutation therefore takes the same * cross-process journal lock and repairs an unterminated tail before writing * the next event. */ import type { JournalMutation, StoredEvent, V3Event } from './event-contract.js'; export type { GoalAsk, GoalAnswer, JournalMutation, StoredEvent, V3ErrorClass, V3BlockedRecovery, V3Event, V3LoopRef, V3RunFailureReason, V3UncertainHostEffect, } from './event-contract.js'; /** * Run one read/check/append mutation under the journal's sole lock. Callers * such as start-intent use this instead of nesting a file lock around * appendEvent (the generic file lock is deliberately non-reentrant). */ export declare function withJournalMutationSync(journalPath: string, fn: (mutation: JournalMutation) => T): T; /** * Append one event as a single NDJSON line. Stamps `ts` (epoch ms) at write * time. Creates the parent directory if missing so the very first * `runStarted` doesn't require the caller to pre-create the runDir. * * Synchronous on purpose: the runtime loop must observe its own writes in * order, and the journal is the linearization point — an async append would * open a window where `decideNext` runs against stale state. */ export declare function appendEvent(journalPath: string, event: V3Event): StoredEvent; /** * Append an event and force both its bytes and a newly-created journal dirent * to stable storage before returning. Reserved for host acknowledgement * boundaries (for example `/start` returning HTTP 202) and resource-close * proofs that must reach disk before a worker fence is removed. Other hot * runtime transitions keep using {@link appendEvent}. */ export declare function appendEventDurable(journalPath: string, event: V3Event): StoredEvent; /** * Read every event in append order. Tolerates a torn FINAL line (crash * mid-append) but throws on any earlier unparseable line — a mid-file parse * failure is real corruption, and silently dropping a middle event would * desync the replayed state (e.g. a lost `nodeSucceeded` leaves the node * looking pending forever), so fail loud instead (codex hardening #11). * Returns `[]` if the file does not exist yet (a run that never started). */ export declare function readJournal(journalPath: string): StoredEvent[]; //# sourceMappingURL=journal.d.ts.map