Skip to main content

Module worktree_copy_transaction

Module worktree_copy_transaction 

Source
Expand description

One journaled installation to an end, resumption from the log, and synchronization of a created worktree. What: One destination’s journaled installation to an end, and the synchronization of every created worktree. The journal records the phase, the install log records each batch’s claims and creations, and a finished or failed installation always removes its journal and stage. Why: A failed installation must not stay pending, because recovery would replay the same failure before every later command; an interrupted one must resume from exactly what it recorded.

In TS you’d write (pseudocode):

const outcome = await completeJournal({ pending, snapshot });

Structs§

TransactionState
What: The mutable durable state of one installation: the latest journal, the open log, and every claim and creation so far. Why: The installer reports claims and creations through this state, so each one reaches disk before the next step.

Enums§

Outcome
What: The result of one installation attempt. Why: A failed installation is an outcome the caller reports, while a journal fault is an error that keeps the state.

Functions§

begin_installing
What: Persists the installing phase before the destination is touched. Why: Recovery must know the installation had started, so it reads the log instead of discarding the stage.
complete_journal
What: Completes one journaled installation and removes its journal and stage, whatever the installation’s outcome. Why: Only a journal that cannot be read or written stays behind, for inspection.
snapshot_from_journal
What: The validated staged payload a journal describes, rebuilt from its stage. Why: Recovery installs from the stage that exists now, and refuses a stage that lost a claimed path.
synchronize_created_worktree
What: Stages, journals and installs the ignored state of one newly created worktree. Why: The stage is removed if the journal cannot be created, and a process that dies while staging leaves a claim, so no stage survives without a record that recovery can act on.