Lockspire.Install.FileTransaction (lockspire v1.6.1)

Copy Markdown

A recoverable filesystem transaction for generated install artifacts.

Lockspire deliberately uses only OTP's portable filesystem API. It validates every existing component with File.lstat/1, refuses links, revalidates before every write, uses exclusive creates, and journals enough information to undo an interrupted update. This is a strong defence against stale plans and ordinary failures, but it is not descriptor-relative openat(2) containment: a hostile same-user process can still replace an ancestor between validation and a path operation. That race needs native O_NOFOLLOW/openat support, which Lockspire intentionally does not ship. Do not run generators in a project tree writable by an untrusted concurrent user.

Summary

Functions

Recovers a previous interrupted transaction, if any, before planning a new one.

Types

artifact()

@type artifact() :: %{
  relative_path: String.t(),
  kind: :migration | :managed | :manifest,
  expected: :absent | String.t(),
  contents: binary(),
  checksum: String.t(),
  provenance: String.t()
}

Functions

apply(project_root, artifacts, opts \\ [])

@spec apply(String.t(), [artifact()], keyword()) :: :ok | {:error, [map()]}

recover(project_root)

@spec recover(String.t()) :: :ok | {:error, [map()]}

Recovers a previous interrupted transaction, if any, before planning a new one.