Interface SessionSelfChange<T>

A memory write a learner session records (memory_write): the write itself, and how to take it back.

interface SessionSelfChange<T> {
    kind: "memory_write";
    actor: string;
    subject: string;
    before: null | MemoryWriteBefore;
    after: Omit<MemoryWriteChange, "brainId">;
    brainId: string;
    apply(): Promise<T>;
    undo(result, reason): Promise<void>;
    keptAfter?(result): Omit<MemoryWriteChange, "brainId">;
    contributorIds?: readonly string[];
}

Type Parameters

  • T = unknown

Methods

  • Takes back what apply wrote. forgotten: the write's user was forgotten once it had committed, so every trace it created, changed or deleted is deleted for good and nothing is restored (a restore would bring back words the deletion removed). unrecorded: its verdict could not be written, or the tombstone could not be read again, so the traces it created are deleted and the ones it changed or deleted come back to their before-state.

    Parameters

    • result: T
    • reason: "forgotten" | "unrecorded"

    Returns Promise<void>

  • What the write did once it committed, where that can differ from what it named before it ran: a write of several traces that resolved some of them to traces their scope already held, or forgot fewer than it meant to. Its kept verdict records this, and a revert takes back this, not the plan; without it the candidate's after stands for both.

    Parameters

    • result: T

    Returns Omit<MemoryWriteChange, "brainId">

Properties

kind: "memory_write"
actor: string

tool:memory_add, memory:rolling_summary.

subject: string

The trace id the write touches, or the id of the set it writes.

before: null | MemoryWriteBefore

What the write replaces: the snapshots of the traces it changes or deletes; null for a write that only adds.

after: Omit<MemoryWriteChange, "brainId">

What the write sets; the layer adds brainId.

brainId: string

The brain the write goes to (Memory.brainId).

contributorIds?: readonly string[]

The users whose words the write files besides the turn's own: a rolling summary's contributors. Before the write runs, the session notes each one's session row (the learner's for the session's learner, a visitor's for anyone else) with the write's brain and conversation, so forgetUser for any of them finds the session, whether or not they wrote there themselves. An anonymous id names no one; a contributor already forgotten gets no row, and the write goes ahead, since the conversation's own history, which forgetUser does not reach, still holds their words.