Module steps
Expand description
Undo, redo, restore and checkpoints written into the document itself, so anyone who can invoke an action can use them: a person, a script, an agent over the action door.
UndoLog is the process’s own stack: it knows
only what this window did, and only while it runs. The verbs here read
the change graph instead, so “undo my last two steps” means the same on
every replica and after a restart, and an agent run is undone by naming
it. Every verb writes forward: the step being undone keeps its author,
and the undo is itself a step that can be undone.
A step belongs to a Scope: an agent run (every invocation of one
agent connection), else the invoking principal, else the writing actor.
What a scope has undone is recorded at UNDONE_KEY root keys, one per
undone change. Ordinary undo writes completion in that same change;
outside compensation stays pending until its admitted receipt confirms it.
A redo removes completed markers through the same selective inversion.
Structs§
- Checkpoint
- A named version.
- Item
Change - How one item differs between two versions.
- Step
Index - A document’s history read once and kept up to date: its changes in causal order and what each one was to the steps of its author. A change’s kind never changes, so it is read once; new changes are read as they arrive.
Enums§
- Scope
- Whose steps an undo or redo takes back.
Constants§
- AGENT_
RUN - The group kind of an agent connection’s invocations.
- BOOKKEEPING_
PREFIX - Prefix every bookkeeping root key shares; a restore leaves them alone.
- CHECKPOINT_
KEY - Prefix of the root keys holding named versions.
- COMMAND_
RUN - The group kind of one command line a shell ran: every file action it and the commands it dispatched carried out, undone as one.
- MAX_
CHECKPOINT_ NAME - Longest checkpoint name.
- MAX_
RESTORE_ PATHS - Maximum number of exact paths accepted by
restore_paths. - MAX_
RESTORE_ PATH_ BYTES - Maximum byte length of one exact restore path.
- TASK_
RUN - The group kind of a workspace task’s invocations: an agent working a native task stamps its steps with the task, so that is the run undo names.
- UNDONE_
KEY - The document key prefix of a step’s undo marker, followed by the step’s
change hash:
trueonce taken back, a negative attempt count while its undo waits for an outside consequence to settle, a positive one while its redo does.
Functions§
- brought_
back - What one redo change brought back, by full hash; empty for any other change.
- changed_
items - The items that differ between
fromandto, in document order, bookkeeping left out. - checkpoint
- Name the document’s current version
name; naming another version with a name in use moves the name. - checkpoints
- Every checkpoint, by name.
- is_
bookkeeping - Whether
patchwrites bookkeeping rather than content. - is_
schema_ genesis - Whether
versionis the schema genesis rather than something a person wrote. See [is_schema_genesis_actor]. - names_
a_ run - Whether a group of this kind is a run that undo can name: an agent’s connection, its run of a task, or one command line of a shell.
- pending_
compensations - Recorded outside inverses which have not confirmed completion. This is descriptive history data; callers must verify the original action too.
- redo
- Bring back the last
limitundos ofscope, as one new change: an outside step through the actionrestoregives for it (its recorded action, run again), any other by reverting the undo. A positive pending marker keeps such a step undone until its restoration settles. Returns the undo changes it brought back, newest first. - redo_
where redoof the undosownsclaims (seeundo_where). Brings back nothing, and says so with an empty list, whenownsclaims no undo in effect.- resolve
- The heads
versionnames: a checkpoint’s name, or a change id from history (at least six hex digits of it) — the document as of that change. - restore
- Bring the document back to
headsas one new change: all of it, or only the items whose keys areids(a mark, a layer, a field). Bookkeeping — what is undone, the checkpoints — stays as it is. Returns how many patches were written. - restore_
paths - Restore only the exact paths listed by
changed_items, writing forward through the same patch machinery asrestore. A root path selects its entire value (including every descendant);map/idselects only that entry. Unlikerestore, an empty selection never means the whole document. - same_
step - Whether
next, the change afterlast, is a change of the same step: of the gesturelastbelongs to (the keystrokes of a word, the values one drag of a slider passes through), or of the invocationlastran in — one action and every action it called, which undo takes back together however many changes it made. - short
- The first twelve hex digits of a change hash: what history lists.
- step_
label - A one-line name of a step for a sentence, in
words. - steps_
in_ effect - took_
back - What one undo change took back, by full hash; empty for any other change.
- undo
- Take back
scope’s lastlimitsteps that are in effect, as one new change indoc’s open transaction: each through the inversecompensategives for it, else by reverting its patches. Returns the steps, newest first. On a refusal some of it may already be written: the caller discards the transaction, as the action executor does for a refused action. - undo_
preview - What
undowould take back forscopenow: its lastlimitsteps in effect, newest first. - undo_
since - Take back every step of
scope’s in effect made after the versionheads, as one new change: back to a checkpoint or a change from history without counting steps. Returns the steps, newest first. - undo_
step - Take back the one step of
scope’s in effect that the changehashis part of (with the rest of its gesture), wherever it stands in history, as one new change: a step a history list names. Returns the step’s changes, newest first. - undo_
where undoof the stepsownsclaims, for a document whose changes name their makers in their own words rather than in an entry (a settings document’s). Takes back nothing, and says so with an empty list, whenownsclaims no step in effect.- undone
- The changes currently undone, by full hash.
- undos_
in_ effect - The undos in effect that
ownsclaims, newest first, at mostlimit(seeStepIndex::undos).
Type Aliases§
- Inverse
- The verified inverse action of a step, when it has one (it queued an outside consequence): applied instead of reverting its patches. Supplied by the caller’s registry; it carries no authority of its own.