Cotal TypeScript packages
    Preparing search index...

    Class CutJournal

    A read-only journal that stops the walk when it first LOOKS UP a named step.

    Before delegating, never after: Journal.lookup marks a key consumed as its first act, so a stop placed after the delegation would put the cut step itself into the prefix — and the child would then replay the very step it was forked to re-run.

    Exported because the fork's correctness claim is about WHICH WALK produced the cut, and a suite that cannot run the wrong walk cannot show the right one is different from it.

    Hierarchy (View Summary)

    Index
    readOnly: boolean
    run: string
    • Append the pending half: the effect is about to be performed.

      AWAIT THIS BEFORE DISPATCHING. The entry carries the request id the handler will submit under, and an identity that is not durable when the work is issued names nothing a resume can find.

      Parameters

      • key: StepKey
      • inputHash: string
      • startedAt: number
      • OptionalrequestId: string

      Returns Promise<JournalEntry>

    • Record the external resource the handler created, before its terminal is awaited.

      Parameters

      • key: StepKey
      • external: Readonly<Record<string, unknown>>

      Returns Promise<void>

    • Account for everything under a settled scope WITHOUT entering a branch.

      A settled scope is delivered from its own entry, so the branches are never walked — and an entry nothing walks is an orphan, which on a migration means "the edit removed this step". The branches were not removed; they were decided. So the subtree is marked consumed explicitly.

      A loser still sitting pending is settled cancelled in the same pass, because that is what it is: the scope resolved without it. Settling the record is NOT the cancellation — the world has to be told separately, which is what cancel.issued tracks — but leaving it pending would make a resumed run try to recover work the scope already decided to abandon.

      Parameters

      • scopeKeyString: string
      • endedAt: number
      • Optionalonly: ReadonlySet<string>

        Restrict the accounting to these branch keys.

        A resume passes nothing and takes the whole subtree, which is correct because the program hash is unchanged and nothing under the scope can have been removed. A MIGRATION passes the losers alone: the branches it does not name are walked instead, so that an effect the edited source removed still shows up as an orphan rather than being accounted for by a scope that never entered it.

      Returns Promise<readonly string[]>

    • How many EFFECTS this run has already dispatched, counted from what is recorded.

      The effect ceiling is a RUN bound (L4009, "Run effect ceiling reached") and the interpreter's counter is per-instance, so without this a run got a fresh allowance at every activation and a runaway loop that crashed periodically could never reach the ceiling. The journal is the only thing that survives an activation, and it already holds the answer.

      Distinct KEYS, not entries: a dispatch writes a pending entry and then a settled one under the same key, and the interpreter counts the dispatch once. A pending entry still counts — the effect was performed, which is exactly why it was written before the handler was called.

      A conclave counts, because its open is a dispatch and the interpreter counts it as one; the other scope kinds dispatch nothing of their own, so their entries do not.

      Parameters

      • Optionalkind:
            | "spawn"
            | "participant"
            | "turn"
            | "ask"
            | "checkpoint"
            | "sleep"
            | "wait"
            | "waitUntil"
            | "notify"
            | "monitor"
            | "conclave"

      Returns number

    • Every entry, in append order. The journal is the prompt context for repair.

      Returns readonly JournalEntry[]

    • Record a hold's own binding, beside the first attempt's external rather than over it.

      Parameters

      • key: StepKey
      • hold: Readonly<Record<string, unknown>>

      Returns Promise<void>

    • Record ONE OBSERVATION onto a pending entry, leaving it pending.

      The counterpart to Journal.settle, and deliberately not a variant of it. settle says "this step has an answer, and every later activation may use it". This says "this is what the world looked like, and it is history rather than an answer": the entry stays pending, so a resume takes the live path and looks again. The two differ in exactly the property #1459 is about, so they are two methods rather than one with a flag — a flag is how the next edit makes an observation settle.

      DURABLE BEFORE IT IS VISIBLE, like every other transition here: the append is awaited before the in-memory entry moves, so a store that refuses leaves the journal exactly as it was.

      Parameters

      • key: StepKey
      • value: unknown
      • at: number

      Returns Promise<JournalEntry>

    • Entries the current replay never looked up. On a migration these are the steps the edited program removed, and what happens next depends on what they DID: a removed sleep is nothing, a removed spawn leaks a live agent, a removed resolved checkpoint discards a human decision.

      Returns readonly JournalEntry[]

    • Point the pending entry at a NEW open identity, before the work under it is issued.

      Escalation mints twice under one entry, so between the hops the row must name the attempt that is about to be open rather than the one that already settled. Without this a crash after the second mint leaves the far side holding work under an identity the journal never recorded, and recovery reissues the first attempt and gets its cached expiry.

      The INDEX moves with the id, and it is the half that recovery reads: an id says what to submit under, the index says how much of the chain is already spent.

      Parameters

      • key: StepKey
      • requestId: string
      • attempt: number

      Returns Promise<void>

    • Start a fresh replay pass.

      Returns void

    • Append the settled half.

      facts.cancel is for a scope that cancels siblings: the intent is recorded WITH the outcome rather than after it, because a process dies between instructions and two appends are two network operations however few keywords separate them. facts.closed is a conclave's membership disposition, for the same reason and with the same rule: it goes down with the outcome or not at all.

      Parameters

      • key: StepKey
      • outcome:
            | { result: unknown; status: "ok" }
            | { error: EntryError; status: "failed" }
            | { status: "cancelled" }
            | { error: EntryError; status: "refused" }
      • endedAt: number
      • Optionalfacts: {
            branchDigest?: string;
            branches?: readonly string[];
            cancel?: { issued: boolean; losers: readonly string[] };
            closed?: boolean;
        }

      Returns Promise<JournalEntry>