Skip to main content

Module exec

Module exec 

Source
Expand description

Execution (SPEC 8.4) and apply commits (SPEC 8.7).

Per target file, holding the store lock: re-read and re-plan if the file changed since planning (up to three times), back up the original bytes, self-check the edited text, write a temp file, compare-and-swap against the planned bytes, replace, then update the ledger and the journal. A failed file never stops the others.

apply_in runs inside a Transaction: the run is recorded in machines/<machine-id>.applied.toml and the Surjection-Apply trailer of that transaction’s single commit. run wraps it in its own transaction, which commits only when a file was written.

Structs§

ApplyReport
The result of an apply run.
ApplyRequest
One apply run’s inputs.
TargetResult
What one target got.

Enums§

ApplyStatus
What an apply run left for the user (ApplyReport::status).
Touched
What a store change touched. Its instant apply plans and writes only those targets (#15), so an unrelated project waiting for trust, or a drifted file elsewhere, neither slows the change nor shows in its result.

Functions§

apply_in
Plans against the transaction’s view of the store (staged edits included), executes, and records the run in the transaction: always when the transaction commits anyway (an instant-mode edit, a rollback), otherwise only when a file was written. Staged edits are validated and leak-scanned first, so an edit the commit would refuse never reaches a client file.
instant_apply
In instant mode (apply_mode, the default), applies a staged store edit inside its transaction, so the edit and its apply are one commit (SPEC 8.7): the targets the edit touched. None in review mode. The desired state is loaded once, for the mode and the plan.
preview
Plans against the store’s working tree (or an empty desired state when there is no store yet). Read-only: creates no ledger key, lock or file.
run
A standalone apply run in its own transaction: one commit when a file was written, none otherwise (SPEC 8.7).