Cotal TypeScript packages
    Preparing search index...

    Interface JournalEntry

    interface JournalEntry {
        attempt?: number;
        branchDigest?: string;
        branches?: readonly string[];
        cancel?: { issued: boolean; losers: readonly string[] };
        closed?: boolean;
        endedAt?: number;
        error?: EntryError;
        external?: Readonly<Record<string, unknown>>;
        hold?: Readonly<Record<string, unknown>>;
        inputHash: string;
        kind: JournalKind;
        name: string;
        observations?: readonly { at: number; value: unknown }[];
        occurrence: number;
        requestId?: string;
        result?: unknown;
        run: string;
        scope: string;
        seq: number;
        startedAt: number;
        state: EntryState;
        status?: EntryStatus;
        v: 1;
    }
    Index
    attempt?: number

    WHICH attempt JournalEntry.requestId names, counted from 0.

    The id alone is not enough to recover an escalation. An escalated checkpoint mints twice under one entry, and a resumed run that knows only the open id cannot tell whether the hop has been spent: it re-runs the live body, mints a second time under the id the far side already holds, and collects that mint's cached expiry as if it were a fresh observation. The index is what makes "complete the open attempt" expressible at all. Absent on an entry written before this rule, which reads as attempt 0 and is correct for every non-escalating effect.

    branchDigest?: string

    branchDigest: what the arms this scope did NOT walk looked like when it ran.

    A settled race is replayed from its own entry, and a migration walks the RECORDED WINNING branch alone — so an edit inside a LOSING arm is invisible to every check the walk performs. Measured, not assumed: editing the winner's arm is caught, editing the loser's arm produced a plan byte-identical to the plan for source that was never edited, and the child ran silently. This binds the losers' bodies into the entry so that edit diverges directly.

    Optional in the entry shape and optional here: it is written only where the branch bodies are literals in the source the interpreter is holding. A race over a variable has no branch node to digest, and inventing one is worse than carrying nothing — hence "compare it IF the entry carries one" rather than "require it".

    branches?: readonly string[]

    branches: the arm names this scope was made of, on a scope that FAILED.

    A successful scope carries them inside result, and settle writes result only when the status is ok — result and error are exclusive, which is right. The consequence was not: a FAILED scope recorded no arm names anywhere, so a migration reconstructed an empty winner set, entered no branch, and awaited Promise.race([]), which never settles. It hung on source nobody had edited. The names are not an outcome; they are what the scope WAS, and a scope that failed was still made of arms.

    Written only on the failed path, because the ok path already carries them and duplicating a fact into two places is how the two come to disagree.

    cancel?: { issued: boolean; losers: readonly string[] }

    A cancelling scope's INTENT, durable with its outcome.

    A journal write cancels nothing by itself: marking a branch cancelled while its agent keeps working is how two agents come to share a worktree, one of them invisibly. So the losers are recorded WITH the result, and issued flips only once the world agrees they are quiescent — which is a fact about the world, established by whoever is driving, not by this record.

    closed?: boolean

    A conclave's CLOSURE, stated rather than inferred from the entry's state.

    The state cannot answer it. A cancelled conclave is settled/cancelled while its membership is deliberately still live, and a scope whose body failed AND whose close failed settled failed too — indistinguishable from "body failed, close succeeded", which an orphan walk reads as closed. So the disposition is its own fact: true only once the handler acknowledged the close. An entry that never settled is open by definition and carries nothing.

    endedAt?: number
    error?: EntryError
    external?: Readonly<Record<string, unknown>>

    The external resource this effect bound, so a crash mid-effect is recoverable.

    hold?: Readonly<Record<string, unknown>>

    The binding of the hold opened for an at-most-once step (spec/cotal-lang.md §7.8). Its own field so the first attempt's external stays on the entry as the write's evidence. An entry carrying it is a held step.

    inputHash: string
    kind: JournalKind
    name: string
    observations?: readonly { at: number; value: unknown }[]

    WHAT THIS STEP HAS OBSERVED SO FAR, and the distinction this field exists to make is the whole of #1459.

    result is what a resume hands back INSTEAD of running the step again. An OBSERVATION is the opposite promise: it is what the world looked like at a moment that has passed, recorded so the history is auditable, and explicitly NOT an answer a later activation may reuse. A waitUntil whose predicate did not hold records the observation here and leaves the entry PENDING, so a resume re-enters the live path and OBSERVES AGAIN.

    Written the other way round — a non-terminal observation settled as the step's result — is precisely the defect: measured on the shape this primitive replaces, a run that observed "pending" once replayed "pending" forever, for a resource that had since completed, and the handler was never called again because lookup answers replay from a settled entry without dispatching. A wait that cannot re-observe is not a wait; it is a cached first glance.

    Only the TERMINAL observation becomes result, because only that one is an answer.

    occurrence: number
    requestId?: string

    The identity the handler submits under, written HERE at begin rather than reported back after the fact. Recovery reissues under it; external is what the handler learned and may be absent entirely if the crash came first.

    result?: unknown
    run: string
    scope: string
    seq: number

    Append order. For reading and rendering ONLY; matching never uses it.

    startedAt: number
    state: EntryState
    status?: EntryStatus
    v: 1